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

Make signal names case-sensitive #1013

Closed
ehmicky opened this issue May 2, 2024 · 1 comment · Fixed by #1025
Closed

Make signal names case-sensitive #1013

ehmicky opened this issue May 2, 2024 · 1 comment · Fixed by #1025

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented May 2, 2024

We should make signal names case-sensitive, always uppercase.

Currently, signal names passed to subprocess.kill() or the killSignal option are case-insensitive. This is inherited from Node.js behavior which was added in Node v8 in the following PR (nodejs/node#10423). This PR does not actually mention this change of behavior (although it's clear both the committer and the reviewer were aware of it), nor is this is mentioned in an issue.

The main cons is that this would be a breaking change.

That being said, this behavior is undocumented in both Execa and Node.js.

Also, the current behavior is inconsistent with process.kill() and os.constants.signals, which are case-sensitive and always uppercase. For example, passing 'sigterm' or 'Sigterm' to subprocess.kill() works, but passing it to process.kill() fails.

Furthermore, uppercase is the convention for signal names. For example, passing a lowercase signal name to the kill Unix utility does not work.

Finally, being stricter would allow us to provide with stricter typing. Typos in signal names are likely, especially with signals like SIGALRM, SIGSTKFLT, SIGCHLD vs SIGCLD (yes, those are two different signals...), SIGSTOP vs SIGTSTP (also two different signals) or SIGVTALRM. It'd be helpful to let TypeScript warn of those typos, but that's not possible if the value is case-insensitive.

What do you think @sindresorhus?

@sindresorhus
Copy link
Owner

I very much agree 👍

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 a pull request may close this issue.

2 participants