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
0
votes
0 answers

nodejs child_process spawn and exec doesn't kill process on process.kill(pid)

I am working in nodejs. I'm trying to run .cmd file using child_process spawn and exec. But none seems to work. Spawn successfully run the .cmd file when I run this script spawn('cmd', ['/c', 'start start_wMBusServices_CLI.cmd']). but on killing…
Zeeshan Malik
  • 627
  • 1
  • 14
  • 31
0
votes
1 answer

Executing child_process in electron-packager

I executing ffmpeg.exe process from Electron app via Node child_process module to get some information. // preload.js const child_process = require("child_process"); const FFMPEG_PATH = require("path").join(__dirname,…
0
votes
1 answer

Why is Bash handling child processes different compared to Sh

The tini init-process, used in Docker, mentions that process group killing is not activated by default and gives the following example: docker run krallin/ubuntu-tini sh -c 'sleep 10' If I run this, and press Ctrl-C immediately after, I indeed have…
Peter
  • 746
  • 6
  • 22
0
votes
2 answers

How to kill a child process in node.js after 10 sec?

I am making an online code runner and it is working well but when it is running into an infinite loop then it is not stopping, so I want to kill this child process if it is being executed more than 10 sec. How can kill the exec process after…
Arnav
  • 97
  • 6
0
votes
1 answer

I'm getting an error when using spawn to run python in my javascript code

I am running the pyhyon script in javascipt, but I am getting an error. Javascript code: const { spawn } = require("child_process"); const python = spawn( "C:/Users/Murat/AppData/Local/Programs/Python/Python39/python.exe", …
0
votes
1 answer

Function is running twice but only being called once?

This code works. It throws an error on the first getClipFile, because ffmpeg hasn't completed. I kind of understand that, but also it's running again somehow? I want to make it run once, after the my bash script has completed. I also cannot…
studstill
  • 65
  • 1
  • 10
0
votes
2 answers

Best way to copy a directory from an external drive to a local folder with electronjs?

Just wondering if anyone has ever attempted to copy a directory from an external drive (connected via USB) to a local folder. I am using ElectronJS so I can use my JavaScript, HTML/CSS skills to create a desktop application without utilising a C…
Patrick Lafferty
  • 337
  • 1
  • 7
  • 20
0
votes
0 answers

Nodejs listing directories with child_process.spawn ends before receiving all data

const spawn = require('child_process').spawn; function main() { ls = spawn('dir', {shell: true}); ls.stdout.on('data', data => console.log('DATA RECEIVED')); ls.on('exit', code => console.log('EXITED')); } main(); This runs on…
0
votes
1 answer

Get exit status of child process on background

Normally, if I want the exit status of a child I just do: int pid=fork(); switch(pid) { case -1: /*Error treatment*/ exit(1); case 0: /*Child part*/ exit(0); default: waitpid(pid,&status,0) WIFEXITED(status); } Then I have the exit status on…
walter
  • 193
  • 9
0
votes
1 answer

Open document to a set screen position with Electron

In an electron app, I want to open a document from the user's computer, and place that file in a specific position on the user's screen. For example, open a locally saved txt file, and display it at the top right of the screen. Hoping for a…
SeanRtS
  • 1,005
  • 1
  • 13
  • 31
0
votes
0 answers

Python SMTPlib as Node.js child process fails at ehlo

I've written a python script using smtplib which can send emails automatically etc. which works perfectly from cmd. However, when I try to spawn the script as a child process from the Node.js server I have running locally which I would like to…
Evander
  • 57
  • 4
0
votes
1 answer

How can i properly send a stream from forked child process in Node.js?

I tried something like this in the forked child process: WriterPlugin.js (child process) function sendCursor(){ try { let cursor = await getQueryCursor(reqBody, db); cursor.on('data', (data)…
Gus Evan
  • 35
  • 4
0
votes
1 answer

How can I execute a command from Typescript and output to cmd prompt

I would like to execute a command from inside a typescript file. The typescript file doesn't have to continue, ideally it would end. The command and all its output would be output to screen, as if it was run from command prompt. I have tried this…
Dan Pettis
  • 113
  • 5
0
votes
1 answer

child processes are not terminating correctly in c

Still new in learning about forks and processes and I have this task to create 3 child processes perform some actions and then the parent should print there exit status as they terminate. The problem I am having is child 1 is terminating earlier and…
william_
  • 1,131
  • 6
  • 20
0
votes
1 answer

NodeJS "fork" child process executing, but not giving parent any indicator when it exits

I am running a for loop which opens up a different fork process on each go. Since I want to limit the total number of concurrent processes, I have a tally which increases by one every time a fork process is initiated, and which is supposed to…