{"record":{"id":"ddcfc0d828016edf","repo":"slimtoolkit/slim","slug":"cannot-append-stop-command-to-fifo-file-w","errorCode":null,"errorMessage":"cannot append stop command to FIFO file: %w","messagePattern":"cannot append stop command to FIFO file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/standalone/control/stop.go","lineNumber":18,"sourceCode":"package control\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/slimtoolkit/slim/pkg/ipc/command\"\n\t\"github.com/slimtoolkit/slim/pkg/util/fsutil\"\n)\n\nfunc ExecuteStopTargetAppCommand(ctx context.Context, commandsFile string) error {\n\tmsg, err := command.Encode(&command.StopMonitor{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot encode stop command: %w\", err)\n\t}\n\n\tif err := fsutil.AppendToFile(getFIFOPath(commandsFile), msg, false); err != nil {\n\t\treturn fmt.Errorf(\"cannot append stop command to FIFO file: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/standalone/control/stop.go#L1-L23","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the commandsFile path matches the one the sensor was started with and that the FIFO file exists.","Confirm the sensor/monitor process is still running to consume the FIFO message.","Check write permissions on the FIFO and its parent directory for the current user.","Inspect the wrapped error from fsutil.AppendToFile for the specific OS failure."],"exampleFix":"// before\ncontrol.ExecuteStopTargetAppCommand(ctx, \"/tmp/wrong-path/commands.json\")\n// after\ncontrol.ExecuteStopTargetAppCommand(ctx, actualSensorCommandsFile) // the path given to the sensor at startup","handlingStrategy":"validation","validationCode":"fifoPath := commandsFile // verify the actual FIFO (getFIFOPath) exists and is writable\nif info, err := os.Stat(fifoPath); err != nil {\n    return fmt.Errorf(\"commands FIFO missing (is the sensor running with this commandsFile?): %w\", err)\n} else if info.Mode()&os.ModeNamedPipe == 0 {\n    return fmt.Errorf(\"%s is not a FIFO\", fifoPath)\n}","typeGuard":null,"tryCatchPattern":"if err := control.ExecuteStopTargetAppCommand(ctx, commandsFile); err != nil {\n    if strings.Contains(err.Error(), \"cannot append stop command\") {\n        log.Errorf(\"could not write stop command to FIFO %s: %v\", commandsFile, err)\n    }\n    return err\n}","preventionTips":["Pass exactly the commandsFile path the sensor was started with.","Confirm the sensor process is still alive before sending stop commands.","Run the control command as the same user that owns the FIFO.","Handle the sensor-exited case explicitly instead of writing to a stale FIFO."],"tags":["ipc","fifo","filesystem"],"backgroundTag":"fifo-write-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}