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

1900 questions
405
votes
27 answers

How do I debug "Error: spawn ENOENT" on node.js?

When I get the following error: events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:1000:11) at Process.ChildProcess._handle.onexit (child_process.js:791:34) What…
laconbass
  • 14,410
  • 6
  • 36
  • 45
191
votes
4 answers

Use child_process.execSync but keep output in console

I'd like to use the execSync method which was added in NodeJS 0.12 but still have the output in the console window from which i ran the Node script. E.g. if I run a NodeJS script which has the following line I'd like to see the full output of the…
suamikim
  • 3,895
  • 6
  • 34
  • 60
99
votes
3 answers

Results of printf() and system() are in the wrong order when output is redirected to a file

I have a C program that compiles to an executable called myprogram. This is its main function: int main(int argc, char ** argv) { printf("this is a test message.\n"); system("ls"); return 0; } When I run myprogram > output.txt in a Linux…
Archr
  • 1,051
  • 6
  • 9
81
votes
1 answer

How to kill childprocess in nodejs?

Created a childprocess using shelljs !/usr/bin/env node require('/usr/local/lib/node_modules/shelljs/global'); fs = require("fs"); var child=exec("sudo mongod &",{async:true,silent:true}); function on_exit(){ …
Deepak Patil
  • 3,000
  • 3
  • 21
  • 21
80
votes
9 answers

How to get child process from parent process

Is it possible to get the child process id from parent process id in shell script? I have a file to execute using shell script, which leads to a new process process1 (parent process). This process1 has forked another process process2(child…
AlwaysALearner
  • 5,329
  • 14
  • 37
  • 52
67
votes
1 answer

NodeJs child_process working directory

I am trying to execute a child process in a different directory then the one of its parent. var exec = require('child_process').exec; exec( 'pwd', { cdw: someDirectoryVariable }, function(error, stdout, stderr) { //…
Jeroen De Dauw
  • 8,671
  • 10
  • 46
  • 71
60
votes
1 answer

Nodejs Child Process: write to stdin from an already initialised process

I am trying to spawn an external process phantomjs using node's child_process and then send information to that process after it was initialized, is that possible? I have the following code: var spawn = require('child_process').spawn, child =…
zanona
  • 11,379
  • 24
  • 78
  • 137
55
votes
4 answers

Running a shell command from Node.js without buffering output

I'm trying to launch a shell command from Node.js, without redirecting that command's input and output -- just like shelling out to a command using a shell script, or using Ruby's system command. If the child process wants to write to STDOUT, I want…
Joe White
  • 87,312
  • 52
  • 206
  • 320
52
votes
2 answers

How to run another python program without holding up original?

What command in python can be used to run another python program? It should not wait for the child process to terminate. Instead, it should continue on. It also does not need to remember its child processes.
PyRulez
  • 9,505
  • 9
  • 37
  • 82
42
votes
3 answers

Difference between ChildProcess close, exit events

When spawning child processes via spawn()/exec()/... in Node.js, there is a 'close' and an 'exit' event on child processes. What is the difference between those two and when do you need to use what?
Narigo
  • 2,519
  • 2
  • 14
  • 25
42
votes
2 answers

Supervisord - Redirect process stdout to console

I am planning to run multiple processes using supervisor and please find my supervisord.conf file below: [supervisord] [program:bash] command=xyz stdout_logfile…
KarthikJ
  • 3,219
  • 5
  • 40
  • 53
38
votes
2 answers

Start another node application using node.js?

I have two separate node applications. I'd like one of them to be able to start the other one at some point in the code. How would I go about doing this?
Hydrothermal
  • 3,988
  • 7
  • 22
  • 43
36
votes
2 answers

Can Visual Studio be made to debug child processes like WinDBG?

This is similar to this question, but I wanted to flesh it out a bit. (I'm new here, if I should instead do a "bump" answer on the previous question instead, please let me know.) In WinDBG, I can use the .childdbg 1 command to tell it to break when…
David Pope
  • 6,099
  • 2
  • 33
  • 45
34
votes
5 answers

How to wait for a child process to finish in Node.js?

I'm running a Python script through a child process in Node.js, like this: require('child_process').exec('python celulas.py', function (error, stdout, stderr) { child.stdout.pipe(process.stdout); }); but Node doesn't wait for it to finish. How…
David
  • 655
  • 1
  • 8
  • 17
34
votes
2 answers

Difference b/w event.on() and event.once() in nodejs

I'm testing the plus_one app, and while running it, I just wanted to clarify my concepts on event.once() and event.on() This is plus_one.js > process.stdin.resume(); process.stdin.on('data',function(data){ var number; try{ …
Anathema.Imbued
  • 2,561
  • 4
  • 15
  • 17
1
2 3
99 100