Questions tagged [child-process]

For questions regarding child-process

In Unix, a child process is typically created as a copy of the parent, using the fork system call. The child process can then overlay itself with a different program (using exec) as required.

Each process may create many child processes but will have at most one parent process; if a process does not have a parent this usually indicates that it was created directly by the kernel.

The inter communication between a child process and a parent process can be done through normal communication schemes such as pipes, sockets, message queues, shared memories.

When a child process terminates, some information is returned to the parent process. When a child process terminates before the parent has called wait, the kernel retains some information about the process, such as its exit status, to enable its parent to call wait later

2233 questions
10
votes
1 answer

Node.js detect a child process exit

I am working in node, as it happens via a visual studio code extension. I successfully create child processes and can terminate them on command. I am looking to run code when the process unexpectedly exits, this appears to be what the "exit" event…
edencorbin
  • 2,569
  • 5
  • 29
  • 44
10
votes
2 answers

child_process.exec/spawn triggers callback/close with npm install command (via Gulp / Shipit)

I'm using Shipit for deployment. On deploy, Shipit checks out the current Git Sha, to a tmp directory, then I run npm install followed by gulp build, then proceed with the deploy. Shipit uses Orchestrator for it's task flow, as Gulp does. Shipit…
Tim Kelty
  • 261
  • 2
  • 13
10
votes
4 answers

NodeJS batch multi processing - child processes in a pool (or multithreading)

NodeJS batch multi threading processing - child processes in a pool. I know a child process is a process, not a thread. I used wrong semantics, because most people know what your intent is when you speak of "multithreading". So I'll keep it in the…
Redsandro
  • 11,060
  • 13
  • 76
  • 106
10
votes
1 answer

How to transfer/stream big data from/to child processes in node.js without using the blocking stdio?

I have a bunch of (child)processes in node.js that need to transfer large amounts of data. When I read the manual it says the the stdio and ipc inferface between them are blocking, so that won't do. I'm looking into using file descriptors but I…
Bartvds
  • 3,340
  • 5
  • 30
  • 42
9
votes
7 answers

Script output is buffered into one message, despite separate echo statements?

I have a shell script with three echo statements: echo 'first message' echo 'second message' echo 'third message' I then run this script in node and collect the output via this code: var child =…
temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
9
votes
3 answers

Node JS - Cannot Kill Process Executed with Child Process Exec

We are trying to kill the process of a chrome browser launched with nodes child_process exec command var process = cp.exec(`"chrome.exe" --app="..."`, () => {}); // working great But when we try process.kill(); //nothing happens... Does the…
user4602228
9
votes
1 answer

EPIPE error in Node.js

The following code run fine on JPEG, Docx, zip and several other file formats. Then I try is on mpg-filer however, I am hit by a "Error: write EPIPE" that I am unable to debug. Using a try/catch construction also result in an uncaught exception. The…
rlp
  • 513
  • 2
  • 7
  • 16
9
votes
3 answers

exec vs execFile nodeJs

I want to run a command in command-prompt using nodejs. Based on https://dzone.com/articles/understanding-execfile-spawn-exec-and-fork-in-node, i used child_process.execFile('protractor', ['./src/convertedJs/tempProtractorconfig.js'], (err, stdout,…
radio_head
  • 1,306
  • 4
  • 13
  • 28
9
votes
1 answer

Node.js child process exits with SIGTERM

I'm spawning a child process using Node 6.9. const child = require('child_process').execFile('command', args); child.stdout.on('data', (data) => { console.log('child:', data); }); child.stderr.on('data', (data) => { console.log('child:',…
mitchkman
  • 6,201
  • 8
  • 39
  • 67
9
votes
4 answers

NodeJs Error: spawn C:\Windows\system32\cmd.exe; ENOENT

This is my script : var exec = require('child_process').exec; exec('dir', function(error, stdout, stderr) { // 'dir' is for example if (error) { console.error(`exec error: ${error}`); return; } …
Jiohn Dioe
  • 91
  • 1
  • 1
  • 2
9
votes
3 answers

SIGSEGV from spawn child_process in AWS Lambda function

I'm trying to spawn a synchronous child process (to run ffprobe) in AWS Lambda function, but it dies almost instantly (200ms) with signal SIGSEGV. My understanding of a segmentation fault is that it is a process that is trying to access memory it…
Chris Paton
  • 5,113
  • 4
  • 41
  • 52
9
votes
5 answers

Stripe with React JS

I need to create token with Stripe.js in React JS, but I can't find any easy way. In node.js I would do something like this: stripeClient.tokens.create({ card: { number: '4242424242424242', exp_month: 12, exp_year:…
Jan Omacka
  • 1,810
  • 4
  • 20
  • 27
9
votes
1 answer

Node.js child processes and pipes - OSX vs Ubuntu

I am trying to get two long running node.js processes to communicate - a parent and a child - using pipes and Node's child-process module. I want the child to be able to send data back to the parent asynchronously, and I was hoping to use a pipe to…
Jacob
  • 131
  • 1
  • 6
9
votes
1 answer

NodeJS: child_process.exec not executing function

I'm attempting to do something I think is very simple -- execute an 'echo' line using child_process.exec. My code looks as such: var exec = require('child_process').exec; exec('echo "HELLO"', function (error, stdout, stderr) { …
streetlight
  • 5,968
  • 13
  • 62
  • 101
9
votes
1 answer

Checking if a child process is running

I've built a portal, one of the pages lists releases from Octopus Deploy. However, some information needed about each release is held inside its zip in a data store (shared drive). I currently get releases from Octopus's API then check a mongo db…
ste2425
  • 4,656
  • 2
  • 22
  • 37