child_process: sync spawn should not return pid number of a non-exist-command
#37057
Labels
child_process
Issues and PRs related to the child_process subsystem.
Is your feature request related to a problem? Please describe.
This strange behavior of sync spawn is found when adding test to #37014 (comment).
Upon adding the test, I found the
pid
value is a bit more complex than I thought:undefined
(expected)shell: false
will get pidundefined
(expected)shell: true
will get pid of the shell (expected)The test code for this:
[test.js]
And the output:
[v15.6.0 linux x64]
[v15.6.0 win32 x64]
On win32 some spawnSync tests return pid
0
, which is strange, so I try tracked the source code,and the main difference is
spawn_sync
set the pid without checking theuv_spawn
result.The sync spawn's code path:
The async spawn code path: (different C++ code)
Describe the solution you'd like
Change the sync spawn to return
pid
similar to the async spawn'ssubprocess.pid
behavior.Describe alternatives you've considered
Or do not return the
pid
for sync spawn?As the process should have exited at the time, and there'll be less use for the
pid
.The text was updated successfully, but these errors were encountered: