Comments (5)
Ah right, thanks for the nice bug report!
A potential fix would be to use a getter instead of assigning the value directly. Want to send a PR?
from child_process.
Yes, I would be happy to try to put together a fix. Can you help me understand why setImmediate()
is being used?
From what I can tell, the node API returns a subprocess with the correct PID synchronously, e.g. this works:
const { spawn } = require('child_process')
console.log(spawn('ls').pid) // => non-zero number
Using a getter to call processIdentifier()
would still return 0 in a case like this, right?
from child_process.
Hum you're right. Tbh I can't remember why I wrapped it in a setImmediate
.
I'm guessing it had to do with making sure the callback is called at the end of the event loop. But maybe it's not necessary
from child_process.
Another problem with using setImmediate
is that exceptions such as :
{ Error: An Obj-C exception occurred. at [native code] (/) at spawn ..... nativeException: <NSException> Couldn't posix_spawn: error 7, line: 817, column: 16
will not get caught in the general catch flow and error
will not get triggered.
From client perspective we cannot know when and what exception occurred.
I created a PR for removing setImmediate
if that sounds reasonable to you.
from child_process.
fixed in 0.4.2
from child_process.
Related Issues (7)
- fork? HOT 1
- Unknown encoding in async process HOT 1
- exec function stdout length HOT 2
- Writing to sdtin crashes sketch HOT 3
- Can use this in browser? HOT 6
- Some async commands hang indefinitely HOT 4
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 child_process.