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
15
votes
1 answer

child_process.fork not starting an express server inside of packaged electron app

I have an electron app where I need not only to run the interface to the user but also start an express server that will serve files for people connected through the network. I have everything working if I start both electron and the express server…
Victor Ivens
  • 2,221
  • 2
  • 22
  • 32
15
votes
4 answers

Spawning a child process with tty in node.js

I am trying to do some work on a remote server using ssh--and ssh is called on the local machine from node.js A stripped down version of the script looks like this: var execSync = require("child_process").execSync; var command = 'ssh -qt…
user1739757
15
votes
1 answer

Node.js: child_process.spawn no output standard output unless 'inherit'

I'm trying to capture standard output from a spawned child_process in Node.js (0.10.29). Right now I'm just trying with ping. The following code doesn't print (but does ping) var exec = require('child_process').exec; var spawn =…
dbenny
  • 151
  • 1
  • 3
14
votes
3 answers

Find all child processes of my own .NET process / find out if a given process is a child of my own?

I have a .NET class library that spins up a secondary process which is kept running until I dispose of the object. Due to some occurances of the program lingering in memory, I've decided to add an integration test to ensure that if I let the object…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
14
votes
2 answers

bash: Why can't I set a trap for SIGINT in a background shell?

Here's a simple program that registers two trap handlers and then displays them with trap -p. Then it does the same thing, but in a child background process. Why does the background process ignore the SIGINT trap? #!/bin/bash echo "Traps on…
Stuart Berg
  • 17,026
  • 12
  • 67
  • 99
14
votes
1 answer

Using a pipe character | with child_process spawn

I'm running nodejs on a raspberry pi and I want to run a child process to spawn a webcam stream. Outside of node my command is: raspivid -n -mm matrix -w 320 -h 240 -fps 18 -g 100 -t 0 -b 5000000 -o - | ffmpeg -y -f h264 -i - -c:v copy -map 0:0 -f…
Titan
  • 5,567
  • 9
  • 55
  • 90
14
votes
2 answers

Stream stdout from child process to browser via expressjs

We have an app built using nodejs, express and child_process.spawn. One requirement is that we need to spawn a process at runtime and capture it's output and present it to the user. We have that working. However, we need to figure out a way to…
user2787799
  • 237
  • 4
  • 9
13
votes
2 answers

Using SSH over Node.js

I'm trying to run a ssh child process in node.js and control it through my program. My code: var util = require('util'); var spawn = require('child_process').spawn; var ssh = spawn('ssh', ['cloudstudios.ch']); ssh.stdout.on('data', function…
Van Coding
  • 24,244
  • 24
  • 88
  • 132
13
votes
3 answers

Detach child process from parent

When a child process forked from a parent dies, it still exists to some extent and is left in a zombie state, until it is reaped from a wait() call. Is is possible to detach this parent-child relationship and have the children be automatically…
Shaggi
  • 1,121
  • 1
  • 9
  • 31
13
votes
1 answer

Node.js - Sending a big object to child_process is slow

My Use-case is as follows: I make plenty of rest API calls from my node server to public APIs. Sometime the response is big and sometimes its small. My use-case demands me to stringify the response JSON. I know a big JSON as response is going to…
Vinoth
  • 131
  • 1
  • 4
13
votes
1 answer

spawning node.js child processes results in zombie processes on cloud foundry

I have a node.js app, and I want to spawn child processes using the code listed below. When I run this app locally, each of the 'ps' commands nicely trigger the close and exit events. On our cloud foundry (pivotal.io) app however, the stdout.close…
mweststrate
  • 4,890
  • 1
  • 16
  • 26
13
votes
2 answers

How to stream to/from a file descriptor in node?

The fs.createReadStream() and fs.createWriteStream() only support file paths but I need to read (or write) from a file descriptor (passed to/from a child process). Note I need Streams, so fs.open/fs.read/fs.write are not sufficient.
Bartvds
  • 3,340
  • 5
  • 30
  • 42
13
votes
3 answers

Stdout of Node.js child_process exec is cut short

In Node.js I'm using the exec command of the child_process module to call an algorithm in Java that returns a large amount of text to standard out which I then parse and use. I'm able to capture it mostly, but when it exceeds a certain number of…
Alex H Hadik
  • 774
  • 2
  • 7
  • 16
13
votes
3 answers

how to get a child process memory usage in node.js?

I know there is a api process.memoryUsage() to get memory usage in current process. But if I start a new child process by child_process.spawn(command, [args], [options]) and I get a ChildProcess object, then how can I get the new process memory…
CALL ME TZ
  • 209
  • 1
  • 4
  • 10
12
votes
1 answer

Sklearn Model (Python) with NodeJS (Express): how to connect both?

I have a web server using NodeJS - Express and I have a Scikit-Learn (machine learning) model pickled (dumped) in the same machine. What I need is to demonstrate the model by sending/receiving data from it to the server. I want to load the model on…
Jean Phelippe
  • 332
  • 2
  • 11