MCPcopy Index your code
hub / github.com/nodejs/node / ChildProcess

Function ChildProcess

lib/internal/child_process.js:255–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253}
254
255function ChildProcess() {
256 FunctionPrototypeCall(EventEmitter, this);
257
258 this._closesNeeded = 1;
259 this._closesGot = 0;
260 this.connected = false;
261
262 this.signalCode = null;
263 this.exitCode = null;
264 this.killed = false;
265 this.spawnfile = null;
266
267 this._handle = new Process();
268 this._handle[owner_symbol] = this;
269
270 this._handle.onexit = (exitCode, signalCode) => {
271 if (signalCode) {
272 this.signalCode = signalCode;
273 } else {
274 this.exitCode = exitCode;
275 }
276
277 if (this.stdin) {
278 this.stdin.destroy();
279 }
280
281 this._handle.close();
282 this._handle = null;
283
284 if (exitCode < 0) {
285 const syscall = this.spawnfile ? 'spawn ' + this.spawnfile : 'spawn';
286 const err = new ErrnoException(exitCode, syscall);
287
288 if (this.spawnfile)
289 err.path = this.spawnfile;
290
291 err.spawnargs = ArrayPrototypeSlice(this.spawnargs, 1);
292 this.emit('error', err);
293 } else {
294 this.emit('exit', this.exitCode, this.signalCode);
295 }
296
297 // If any of the stdio streams have not been touched,
298 // then pull all the data through so that it can get the
299 // eof and emit a 'close' event.
300 // Do it on nextTick so that the user has one last chance
301 // to consume the output, if for example they only want to
302 // start reading the data once the process exits.
303 process.nextTick(flushStdio, this);
304
305 maybeClose(this);
306 };
307 if (childProcessChannel.hasSubscribers) {
308 childProcessChannel.publish({
309 process: this,
310 });
311 }
312}

Callers

nothing calls this directly

Calls 5

maybeCloseFunction · 0.70
closeMethod · 0.65
destroyMethod · 0.45
emitMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…