-
Notifications
You must be signed in to change notification settings - Fork 244
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
Changed unix version of .kill function to send signals to all processes #169
Conversation
Just one remark - imho AIX has none of the ioctls, might be better to change the #error into a warning and import |
… process.kill for .kill function otherwise
Ok, now it should output a warning, not export PtyKill, and fall back to process.kill if TIOCSIG and TIOCSIGNAL aren't available. |
LGTM 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few minor comments
src/unixTerminal.ts
Outdated
} | ||
} catch (e) { /* swallow */ } | ||
} else { | ||
// Unknown signal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's throw a new Error
here to make known that nothing happened.
src/unixTerminal.ts
Outdated
signal = signal || 'SIGHUP'; | ||
if (signal in os.constants.signals) { | ||
try { | ||
if (pty.kill && signal !== 'SIGHUP') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining why this is needed would be good here.
src/unix/pty.cc
Outdated
NAN_METHOD(PtyKill) { | ||
Nan::HandleScope scope; | ||
|
||
if (info.Length() != 2 || !info[0]->IsNumber()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have check the type of info[1]
…ignal is specified
Ok, I've made the changes. |
Thanks! 😃 |
It's complicated. See: #206
TLDR: The ioctl had some limitations I wasn't aware of which had lead to
a regression.
I made a merge request to fix it, but the project had changed to the
microsoft organisation, and thus started requiring a CLA.
For ideological reasons, I do not sign any CLAs. Never ever. It is
understandable that this MR was reverted too as a result.
That said, I'm not sure if this is still the best way to handle such
things anymore anyway.
It seams for some signals, there are ways to assign escape sequences
that will generate a signal to a tty.
https://unix.stackexchange.com/questions/362559/list-of-terminal-generated-signals-eg-ctrl-c-sigint#answer-362579
So just sending the appropriate escape sequence to the ptm is probably a
better solution, although I haven't tested this.
And to make sure really all started programs get a signal, for example
to terminate them, there are probably better although more complicated
ways to do that involving cgroups.
|
This patch changes the unix version of the .kill function to send the signal to all processes of the process group of the pts using the TIOCSIG or TIOCSIGNAL ioctl, except for the SIGHUP signal, for which the original behaviour is retained.
See #167 for details