{"record":{"id":"27b622596956bc13","repo":"sipeed/picoclaw","slug":"udevadm-stdout-pipe-w","errorCode":null,"errorMessage":"udevadm stdout pipe: %w","messagePattern":"udevadm stdout pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/devices/sources/usb_linux.go","lineNumber":60,"sourceCode":"func NewUSBMonitor() *USBMonitor {\n\treturn &USBMonitor{}\n}\n\nfunc (m *USBMonitor) Kind() events.Kind {\n\treturn events.KindUSB\n}\n\nfunc (m *USBMonitor) Start(ctx context.Context) (<-chan *events.DeviceEvent, error) {\n\tm.mu.Lock()\n\tdefer m.mu.Unlock()\n\n\t// udevadm monitor outputs: UDEV/KERNEL [timestamp] action devpath (subsystem)\n\t// Followed by KEY=value lines, empty line separates events\n\t// Use -s/--subsystem-match (eudev) or --udev-subsystem-match (systemd udev)\n\tcmd := exec.CommandContext(ctx, \"udevadm\", \"monitor\", \"--property\", \"--subsystem-match=usb\")\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"udevadm stdout pipe: %w\", err)\n\t}\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, fmt.Errorf(\"udevadm start: %w (is udevadm installed?)\", err)\n\t}\n\n\tm.cmd = cmd\n\teventCh := make(chan *events.DeviceEvent, 16)\n\n\tgo func() {\n\t\tdefer close(eventCh)\n\t\tscanner := bufio.NewScanner(stdout)\n\t\tvar props map[string]string\n\t\tvar action string\n\t\tisUdev := false // Only UDEV events have complete info (ID_VENDOR, ID_MODEL); KERNEL events come first with less info\n\n\t\tfor scanner.Scan() {\n\t\t\tline := scanner.Text()","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/devices/sources/usb_linux.go#L42-L78","documentation":"During USBMonitor.Start, cmd.StdoutPipe() on the udevadm monitor command failed before the process was even started. StdoutPipe only fails if the internal pipe/synchronization structures cannot be created (effectively an allocation failure), so this is a defensive branch - in practice you will never see it. The companion error at line 64 (udevadm start) is the realistic startup failure.","triggerScenarios":"No realistic runtime trigger; StdoutPipe on a freshly built exec.Cmd returns an error only under memory-exhaustion-level conditions. Everything environmental (missing udevadm, bad flags) surfaces later at cmd.Start() as the line-64 error.","commonSituations":"Practically never observed. If reported, suspect OOM conditions on the host rather than a udev or configuration problem.","solutions":["Treat as an internal/resource failure: check host memory pressure (`dmesg | grep -i oom`) and restart the monitor","Do not spend time on udev configuration for this specific error - it is not a udev issue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := monitor.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"udevadm stdout pipe\") {\n        // resource-level failure (near-OOM); restart the service rather than debugging udev\n        return fmt.Errorf(\"internal resource failure starting usb monitor: %w\", err)\n    }\n    return err\n}","preventionTips":["Watch host memory pressure; this branch implies allocation-level failure","Do not misdiagnose as a udev configuration issue - the udevadm process never started"],"tags":["linux","udev","devices","internal","defensive"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}