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

killing the subcommand if the main command is terminated #411

Closed
wants to merge 13 commits into from

Conversation

thomashoffmann1979
Copy link

The sub command keeps running if the main command was killed. I added listeners to that events to terminate the sub command.

@@ -1100,4 +1109,3 @@ function exists(file) {
return false;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the newline here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my atom editor kills extra lines. I add the line again.

@SomeKittens
Copy link
Collaborator

Tests would be great, 👍 otherwise

@zhiyelee
Copy link
Collaborator

Should it be an option or default?

@thomashoffmann1979
Copy link
Author

I think this should be the default behavior. If you try to store the process pid, you will get only the pid of the main process.

mycommand service  1> /tmp/log.txt 2>&1 &

Returns something like:

[1] 55274

ps aux | grep mycommand shows:

me  55275   0,0  0,3  3073148  50068 s000  S    10:05am   0:00.40 node ./bin/mycommand-service
me  55274   0,0  0,3  3069368  46176 s000  S    10:05am   0:00.32 node ./bin/mycommand service

If you try to kill that pid (55274), the sub command (55275) keeps running.

}
process.on('exit',processClosing );
process.on('SIGINT', processClosing );
process.on('SIGHUB', processClosing );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGHUP? Have you test all this listener? @thomashoffmann1979

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGHUP seem to be right see https://en.wikipedia.org/?title=SIGHUP. I will add a test for it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. To double check, I mean here we should use SIGHUP instead of SIGHUB.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right! I will fix it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it. Now the exit signal of the main process is used for the sub command, too.

@zhiyelee
Copy link
Collaborator

Hi @thomashoffmann1979 , we can merge this if you add a test. Thank you.

@SomeKittens
Copy link
Collaborator

This should be default in my opinion - seems expected behavior to kill the whole process.

@dlmr
Copy link

dlmr commented Oct 8, 2015

Is the only thing that prevents this from being merged that it has conflicts?

Would really like this functionality included in Commander.js.

@zhiyelee
Copy link
Collaborator

zhiyelee commented Oct 8, 2015

@thomashoffmann1979 Can you solve the conflict in this PR. I will merge it.

@dlmr
Copy link

dlmr commented Nov 2, 2015

Seems like the build fails for Node.js v0.6 and v0.8. Is this still something that should be supported and have anyone looked into what the cause is?

@SomeKittens
Copy link
Collaborator

@dlmr IIRC, we're still supporting v0.8. Dropping it would be a major version change. See #431

@roman-vanesyan
Copy link
Collaborator

closing in favor of #632

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

Successfully merging this pull request may close these issues.

None yet

5 participants