gillesdemey / node-record-lpcm16

:microphone: Records a 16-bit signed-integer linear pulse modulation code encoded audio file.
ISC License
212 stars 59 forks source link

send SIGINT instead of SIGTERM? #27

Closed mreinstein closed 7 years ago

mreinstein commented 7 years ago

from the sox/rec man page:

Stopping SoX Usually SoX will complete its processing and exit automatically once it has read all available audio data from the input files.

If desired, it can be terminated earlier by sending an interrupt signal to the process
(usually by pressing the keyboard interrupt key which is normally Ctrl-C).

A Ctrl-C is a SIGINT signal I believe. But the code calls cp.kill() which according to node docs, omitting an argument sends SIGTERM (https://nodejs.org/dist/latest-v7.x/docs/api/child_process.html#child_process_child_kill_signal)

I think this change should be safe, since both sox and arecord will exit on a SIGINT.

From the arecord man page:

SIGNALS When recording, SIGINT, SIGTERM and SIGABRT will close the output file and exit.

@gillesdemey thoughts? I don't know if using sigterm is preventing the child process from exiting cleanly but this might be a good change to follow the documentation for rec. If this is appealing happy to send a PR.

gillesdemey commented 7 years ago

Both SIGTERM and SIGINT are trapped and execute the same code so clean up routines are handled properly.

I don't think this is likely to change any time soon, if ever.

https://sourceforge.net/p/sox/code/ci/master/tree/src/sox.c#l1793

mreinstein commented 7 years ago

Ah ok, so this is a case of the sox manpage omitting details. Thanks!