slimtoolkit/slim · error

cannot append stop command to FIFO file: %w

Error message

cannot append stop command to FIFO file: %w

What it means

After encoding, ExecuteStopTargetAppCommand appends the message to the commands FIFO (derived from commandsFile via getFIFOPath) using fsutil.AppendToFile. This error wraps any failure of that append, so the stop command never reaches the monitoring process.

Source

Thrown at pkg/app/sensor/standalone/control/stop.go:18

package control

import (
	"context"
	"fmt"

	"github.com/slimtoolkit/slim/pkg/ipc/command"
	"github.com/slimtoolkit/slim/pkg/util/fsutil"
)

func ExecuteStopTargetAppCommand(ctx context.Context, commandsFile string) error {
	msg, err := command.Encode(&command.StopMonitor{})
	if err != nil {
		return fmt.Errorf("cannot encode stop command: %w", err)
	}

	if err := fsutil.AppendToFile(getFIFOPath(commandsFile), msg, false); err != nil {
		return fmt.Errorf("cannot append stop command to FIFO file: %w", err)
	}

	return nil
}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Verify the commandsFile path matches the one the sensor was started with and that the FIFO file exists.
  2. Confirm the sensor/monitor process is still running to consume the FIFO message.
  3. Check write permissions on the FIFO and its parent directory for the current user.
  4. Inspect the wrapped error from fsutil.AppendToFile for the specific OS failure.

Example fix

// before
control.ExecuteStopTargetAppCommand(ctx, "/tmp/wrong-path/commands.json")
// after
control.ExecuteStopTargetAppCommand(ctx, actualSensorCommandsFile) // the path given to the sensor at startup
Defensive patterns

Strategy: validation

Validate before calling

fifoPath := commandsFile // verify the actual FIFO (getFIFOPath) exists and is writable
if info, err := os.Stat(fifoPath); err != nil {
    return fmt.Errorf("commands FIFO missing (is the sensor running with this commandsFile?): %w", err)
} else if info.Mode()&os.ModeNamedPipe == 0 {
    return fmt.Errorf("%s is not a FIFO", fifoPath)
}

Try / catch

if err := control.ExecuteStopTargetAppCommand(ctx, commandsFile); err != nil {
    if strings.Contains(err.Error(), "cannot append stop command") {
        log.Errorf("could not write stop command to FIFO %s: %v", commandsFile, err)
    }
    return err
}

Prevention

When it happens

Trigger: fsutil.AppendToFile failing because the FIFO path does not exist, the FIFO was never created by the sensor, there is no reader on the other end (or blocking rules fail), or the caller lacks write permission.

Common situations: Wrong commandsFile path passed to the control command; sensor already exited and removed its FIFO; running as a different user than the sensor; commandsFile pointing to a directory that was cleaned up.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/ddcfc0d828016edf. Report an issue: GitHub.