Comments (10)
I also got confused between those two properties while checking this issue. Should we rename execaError.killed to avoid that confusion? For example execaError.aborted, execaError.terminated, or anything else?
Yes. I prefer using is
or was
prefix for the property.
from execa.
I was looking into implementing this but I need some help first. In the spawned.on('exit')
handler I wanted to set spawned.killed
to true
if the signal indicates that it was killed. But what signals indicate a kill? Or can we check it in a different way?
I was now checking for SIGTERM
and SIGINT
but don't think that's enough.
from execa.
@SamVerschueren I think https://github.com/Tapppi/async-exit-hook/blob/master/index.js#L89-L94 is a good enough list
from execa.
I've opened an issue with Node.js to make childProcess.killed
true
even when the child process was killed through process.kill()
or kill
in the terminal (as opposed to childProcess.kill()
).
from execa.
But what signals indicate a kill?
If signal != null
in proc.on('exit', (code, signal) => { /* ... */ })
, then that's the signal that terminated the process.
If your question is "how do I determine whether it's sent by kill(2)", the answer is "you don't." :-)
from execa.
Yes I think @bnoordhuis fix for it (checking signal
on exit
) is the correct one. However I still think that providing this as part of Node.js might be a good idea (as opposed to execa
).
from execa.
From the discussion at nodejs/node#27490, it appears childProcess.killed
just means "childProcess.kill()
was called". Regardless of whether it terminated the process. For example childProcess.kill(0)
sets childProcess.killed
as true
. The purpose of childProcess.killed
seems to be mostly about idempotency, e.g. preventing calling childProcess.kill()
multiple times.
Instead, that discussion highlights that the best way to check this is to look at the signal
that is passed as a second argument to the exit
event of the child process.
In other words, we might want to replace:
Line 84 in fcf648e
By:
error.killed = error.signal !== undefined;
The documentation says:
signal The signal by which the child process was terminated.
So, we can assume that if a signal is passed, it was the one that terminated the child process.
What do you think?
from execa.
👍
We should document that it differs from the one in Node.js.
from execa.
There is actually a difference between:
childProcess.killed
: left as is by Execa, i.e. has the same behavior as core Node.js. It only checks whetherchildProcess.kill()
has been called (even.kill(0)
), to prevent from calling it several times.execaError.killed
: intended to check whether the child process was "killed", i.e. terminated by a signal. At the moment, it does not behave as such. Instead it behaves likechildProcess.killed
, which can probably be considered a bug.
I.e. since execaError.killed
is an Execa addition, we do not differ from Node.js behavior.
I also got confused between those two properties while checking this issue. Should we rename execaError.killed
to avoid that confusion? For example execaError.aborted
, execaError.terminated
, or anything else?
from execa.
Sounds good. Done at #625.
from execa.
Related Issues (20)
- Graceful termination HOT 1
- Document idiomatic ternary interpolation pattern? HOT 2
- TypeError: The "eventTargets" argument must be an instance of EventEmitter or EventTarget. Received an instance of AbortSignal HOT 7
- Feature request: Possibility to use a custom verbose log format? HOT 5
- stdout/stderr with 'inherit' + transform should not capture output HOT 2
- Unable to extend env when `ProcessEnv` has been manipulated HOT 7
- Typescript: Verbose option type mismatch? HOT 2
- Memory Leak of pipe HOT 3
- `parseCommandString()` splits at whitespace inside quotes HOT 3
- Timeout / cancel stuck process HOT 4
- The command cannot be executed HOT 1
- Intl needed for v. 9 HOT 10
- Error: Premature close HOT 23
- Small package alternative to Execa HOT 9
- Add a link to `nano-spawn`
- How to get both live and programmatic output? HOT 3
- How to stop execa from escaping? HOT 6
- Documentation markup problem in `execa/docs/api.md` HOT 3
- Intellisense isn't working as expected on execa Options HOT 7
- How to prevent broken pipe (SIGPIPE) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from execa.