0

I am catching SIGINT signal to gracefully shutdown app. I am use child process which I would like to keep till I complete shutdown (by default child process have same process group and it recievs signal same time). I use spawn to start child process and try to use it with gid option.

            var child = spawn(pathToFFMPEG,[
                '-t',  duration,
                '-i', station.streamEndpoint,
                '-f', 'mp3',
                'pipe:1'
            ],{
                gid: Math.ceil(Math.random()*100000)
            })

I got ENOTSUP error when I try to start child process (without gid option process starts normally).

How to correct set up process group for child process using spawn? In my example I generate gid randomly but it seems it's not good idea even without above error. I read this article before my experiment with gid . Thanks.

Edit

It seems gid is not supported (at least directly setting it). Are there any options to avoid closing child process with SIGINT signal?

Anton Putau
  • 632
  • 1
  • 7
  • 31
  • How is `SIGINT`a factor here? Windows doesn't implement POSIX signals, so the only `SIGINT` that exists has to be a function of a runtime library. Usually it's the C runtime library, which raises `SIGINT` in response to a console `CTRL_C_EVENT`. – Eryk Sun Dec 27 '17 at 23:12
  • 1
    I don't see a way to explicitly pass the normal process creation flags via node.js `spawn`. I see that specifying `detached` passes the flag to create a new group, but whoever wrote this line -- [`process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP`](https://github.com/nodejs/node/blob/v9.x/deps/uv/src/win/process.c#L1073) -- needs to spend more time researching how the console works and how it uses process groups. They documented this option as "[t]he child will have its own console window". No, it won't have any console, and thus creating a new process group is really pointless. – Eryk Sun Dec 27 '17 at 23:14

0 Answers0