Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commander.js signal handling kills process and means sub-commands cant handle signals #1210

Closed
pgebheim opened this issue Mar 6, 2020 · 5 comments

Comments

@pgebheim
Copy link

pgebheim commented Mar 6, 2020

var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];

In order to get around this, a non-executable command that needs to watch for SIGINT needs to deregister all SIGINT handlers manually in order to capture it itself.

This is a very odd set of behavior.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Mar 6, 2020

That behaviour got added so that a spawned subcommand would be terminated when the "program" was terminated: #411 #632

I am not sure from your description what your setup is. Do you have a program with a SIGINT handler that calls .parse() and spawns a long running subcommand?

Would Commander not adding a listener (handler) if there is one already work for your use case?

@shadowspawn
Copy link
Collaborator

An answer was provided, and no further activity in a month.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

@alexnix
Copy link

alexnix commented Dec 15, 2021

Hi,

Having an issue that might be related, so I am asking it here: i am starting WebpackDevServer from within a command.
WebpackDevServer will initiate graceful shutdown on the first Cmd+C then wait for some file watches to be closed and finish when this is done, or on a second Cmd+c. Detailed here.

Issue is, in my setup, when i press cmd+c the terminal immediately changes as if the command stopped immediately, but then not only it prints additional message from webpack (the one about graceful stopping) but also, the terminal is left in a state where non asci characters (such as up/down arrows) are printed as ^[OA^[OB.

Wondering if this behaviour could be related to what is described in this issue.

Have to mention that if i send SIGINT from htop or kill it works correctly, tho.

@shadowspawn
Copy link
Collaborator

Commander only listens for the signals when it is running a subcommand as a stand-alone executable. If you aren't using a subcommand implemented as a stand-alone executable when the problem occurs, then your problem is not related to this issue.

@alexnix
Copy link

alexnix commented Dec 15, 2021

My command is implemented using the .action((args) => {}) syntax. I guess then it is not the case of this issue. Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants