From 6e01827c7defb62fab64a87b09bed8a5e358d99d Mon Sep 17 00:00:00 2001 From: Helmi Pradita Date: Mon, 2 Nov 2026 14:04:49 +0700 Subject: [PATCH] doc: clarify spawnSync waits for stdio EOF Clarify that child_process.spawnSync() blocks until all stdio streams reach EOF, which means inherited file descriptors held by background descendant processes can keep spawnSync() waiting until all descriptors close or a timeout is reached. Fixes: https://github.com/nodejs/node/issues/67197 Assisted-by: OpenCode Signed-off-by: Helmi Pradita --- doc/api/child_process.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 6ac072beedb4..90848647b37c 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1432,7 +1432,11 @@ changes: The `child_process.spawnSync()` method is generally identical to [`child_process.spawn()`][] with the exception that the function will not return -until the child process has fully closed. When a timeout has been encountered +until the child process has fully closed and all stdio streams have reached EOF. +If the spawned process spawns a detached background child that inherits standard +I/O streams, those open descriptors can keep stdio streams open after the spawned +process has exited, causing `spawnSync()` to wait until all descriptors close or +the configured `timeout` expires. When a timeout has been encountered and `killSignal` is sent, the method won't return until the process has completely exited. If the process intercepts and handles the `SIGTERM` signal and doesn't exit, the parent process will wait until the child process has