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
39
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,457
  • 2
  • 35
  • 45
30
votes
3 answers

How to catch an ENOENT with nodejs child_process.spawn?

I am using spawn to spawn a long running process that sends output over time to stdio, and is read and processed by my nodejs script. The tricky part is that I cannot guarantee that the command sent will always be valid. How can I catch an error…
Fizzbuzz97
  • 719
  • 1
  • 6
  • 14
29
votes
5 answers

Node js get and set data from different process

I've node application which done spawn(child process) to and application, the application have host and port: var exec = require('child_process').spawn; var child = exec('start app'); console.log("Child Proc ID " + child.pid) child.stdout.on('data',…
user4209821
29
votes
3 answers

Launch a completely independent process

I want to initiate a process from my python script main.py. Specifically, I want to run the below command: `nohup python ./myfile.py &` and the file myfile.py should continue running, even after the main.py script exits. I also wish to get the pid…
Garfield
  • 2,487
  • 4
  • 31
  • 54
28
votes
4 answers

Hide child process console window

When spawning a new child in nodejs on windows (child_process.spawn) it always opens a blank console window which stays open until the child process ends. Is there a way to avoid this? i.e. we want to run our application as a background service…
ronag
  • 49,529
  • 25
  • 126
  • 221
26
votes
2 answers

kill all child_process when node process is killed

How do i make sure all child_process are killed when the parent process is killed. I have something like the below one. Even when the node process is kill i see that FFMPEG continues to run and the out.avi is generated. How can i stop FFMPEG from…
Phani
  • 1,704
  • 3
  • 13
  • 18
25
votes
2 answers

How to read child_process.spawnSync stdout with stdio option 'inherit'

var childProcess = cp.spawnSync(command, args, { cwd: process.cwd(), env: process.env, stdio: 'inherit', encoding: 'utf-8' }); childProcess.output always eq [null, null, null] process.stdout.write hook doesn't give me any output
nitro-n
  • 423
  • 1
  • 5
  • 9
25
votes
1 answer

Nodejs - process hangs on exit (Ctrl+C)

I have a node.js project which does many things, it spawns child processes, it opens an http and socket.io server, etc.. When I run it from the console, closing it with Ctrl+C, it just hangs. From webstorm, stopping the process is a two-step…
Madd0g
  • 3,841
  • 5
  • 37
  • 59
24
votes
3 answers

Anyway to get the ID of processes created by Supervisord?

I need the process ID of processes created using supervisord for use in a script. Processes spawned by supervisord don't create .pid files in their default directories, if at all. How do I get the process ID of a supervisord child process?
user1561108
  • 2,666
  • 9
  • 44
  • 69
23
votes
4 answers

Multiple child process

can someone help me about how to create multiple child processes which have the same parent in order to do "some" part of particular job? for example, an external sorting algorithm which is applied with child processes; each child process sorts a…
israkir
  • 2,111
  • 7
  • 30
  • 39
22
votes
2 answers

How to pass messages as well as stdout from child to parent in node.js child process module?

I am having a problem with child-process module, specifically with child.spawn and child.fork. I am relying on the documentation of child_process.fork, which says: This is a special case of the child_process.spawn() functionality for spawning…
Sunny
  • 9,245
  • 10
  • 49
  • 79
22
votes
3 answers

Not receiving stdout from nodejs spawned process

I'm trying to have nodejs interact with adventure, an old text based game. The idea is to open adventure as a child process and then play the game by writing to its stdin and placing an event listener on stdout. When the game starts, it prints an…
ctag
  • 574
  • 2
  • 4
  • 15
22
votes
4 answers

Nodejs child_process.exec : Disable printing of stdout on console

I am performing an image magick identify command via nodejs child_process.exec. and using the string returned from stdout in my script. Everything works fine but the call prints the stdout msg on console, if the server is not restarted and the…
hussainb
  • 1,218
  • 2
  • 15
  • 33
22
votes
3 answers

nodejs/express - stream stdout instantly to the client

I spawned the following child: var spw = spawn('ping', ['-n','10', '127.0.0.1']) and I would like to receive the ping results on the client side (browser) one by one, not as a whole. So far I tried this: app.get('/path', function(req, res) { ... …
anvarik
  • 6,417
  • 5
  • 39
  • 53
20
votes
5 answers

Retaining output colors when shelling out to node

I have a little Grunt task that shells out via node and runs "composer install". var done = this.async(); var exec = require('child_process').exec; var composer = exec( 'php bin/composer.phar install', function(error, stdout, stderr) { …
Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79