sipeed/picoclaw · error

udevadm stdout pipe: %w

Error message

udevadm stdout pipe: %w

What it means

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.

Source

Thrown at pkg/devices/sources/usb_linux.go:60

func NewUSBMonitor() *USBMonitor {
	return &USBMonitor{}
}

func (m *USBMonitor) Kind() events.Kind {
	return events.KindUSB
}

func (m *USBMonitor) Start(ctx context.Context) (<-chan *events.DeviceEvent, error) {
	m.mu.Lock()
	defer m.mu.Unlock()

	// udevadm monitor outputs: UDEV/KERNEL [timestamp] action devpath (subsystem)
	// Followed by KEY=value lines, empty line separates events
	// Use -s/--subsystem-match (eudev) or --udev-subsystem-match (systemd udev)
	cmd := exec.CommandContext(ctx, "udevadm", "monitor", "--property", "--subsystem-match=usb")
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, fmt.Errorf("udevadm stdout pipe: %w", err)
	}

	if err := cmd.Start(); err != nil {
		return nil, fmt.Errorf("udevadm start: %w (is udevadm installed?)", err)
	}

	m.cmd = cmd
	eventCh := make(chan *events.DeviceEvent, 16)

	go func() {
		defer close(eventCh)
		scanner := bufio.NewScanner(stdout)
		var props map[string]string
		var action string
		isUdev := false // Only UDEV events have complete info (ID_VENDOR, ID_MODEL); KERNEL events come first with less info

		for scanner.Scan() {
			line := scanner.Text()

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Treat as an internal/resource failure: check host memory pressure (`dmesg | grep -i oom`) and restart the monitor
  2. Do not spend time on udev configuration for this specific error - it is not a udev issue
Defensive patterns

Strategy: try-catch

Try / catch

if _, err := monitor.Start(ctx); err != nil {
    if strings.Contains(err.Error(), "udevadm stdout pipe") {
        // resource-level failure (near-OOM); restart the service rather than debugging udev
        return fmt.Errorf("internal resource failure starting usb monitor: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: Practically never observed. If reported, suspect OOM conditions on the host rather than a udev or configuration problem.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/27b622596956bc13. Report an issue: GitHub.