Skip to content

SIGUSR1 restart crashes on Windows: EBADF bad file descriptor #19819

@Stache73

Description

@Stache73

Description

SIGUSR1-triggered gateway restarts consistently crash on Windows 10 with an \EBADF: bad file descriptor, write\ error. The spawned child process inherits file descriptors from the parent that are already closed/invalid by the time it tries to write to stdout/console.

Steps to Reproduce

  1. Run OpenClaw gateway on Windows 10 (native, not WSL)
  2. Trigger a restart via \config.patch\ (which sends SIGUSR1 internally)
  3. The gateway receives the signal, spawns a new process, then the new process crashes

Expected Behavior

The gateway should restart cleanly via SIGUSR1, as it does on Linux/macOS.

Actual Behavior

The spawned child process immediately crashes:

\
[openclaw] Uncaught exception: Error: EBADF: bad file descriptor, write
at writeSync (node:fs:922:3)
at SyncWriteStream._write (node:internal/fs/sync_write_stream:27:5)
at writeOrBuffer (node:internal/streams/writable:570:12)
at _write (node:internal/streams/writable:499:10)
at Writable.write (node:internal/streams/writable:508:10)
at console.value (node:internal/console/constructor:298:16)
at console.log (node:internal/console/constructor:384:26)
at writeConsoleLine (file:///...openclaw/dist/subsystem-oVAQxyhr.js:403:32)
at emit (file:///...openclaw/dist/subsystem-oVAQxyhr.js:432:3)
at Object.info (file:///...openclaw/dist/subsystem-oVAQxyhr.js:453:28)
\\

The gateway log shows:

  1. \signal SIGUSR1 received\

  2. eceived SIGUSR1; restarting\

  3. estart mode: full process restart (spawned pid XXXXX)\
  4. \Uncaught exception: Error: EBADF: bad file descriptor, write\

The gateway does not come back up — manual restart is required.

Environment

  • OS: Windows 10 (10.0.19045) x64
  • Node: v24.6.0
  • OpenClaw: v2026.2.17 (4134875)
  • Gateway mode: local, bind: lan
  • Auth: token mode (Claude Max OAuth)

Workaround

Manual restart via \openclaw gateway stop && openclaw gateway start\ or a PowerShell restart script.

Notes

This is 100% reproducible — every SIGUSR1 restart attempt on this Windows machine fails the same way. The issue appears to be that the spawned child process inherits stdio file descriptors from the dying parent, but on Windows these become invalid (EBADF) before the child can use them. On Unix this likely works because of different fd inheritance semantics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions