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

How can I use a child's PID from a parent to shut down a pipe?

I'm using c language in Linux. I have set up code to create a bidirection pipe between a child process and a parent process. I'm able us the pipe for bidirectional communication. However, I'm supposed to use the pid, process id, of the child…
John Alway
  • 65
  • 10
0
votes
1 answer

Node.js how to synchronously read lines from stream.Readable

I'm interacting with a child process through stdio, and I need to wait for a line from childProcess.stdout each time I write some command to childProcess.stdin. It's easy to wrap an asynchronous method for writing like below: async function…
0x269
  • 688
  • 8
  • 20
0
votes
1 answer

Run exe with admin perms in node js

I want to start an exe-file as admin with node. Tried something like this, but this dont want to work: exec('runas /user:Administrator "app.exe"', function(err, data) { console.log(err) }); Im always…
0
votes
1 answer

InternalError Metro has encountered an error: While trying to resolve module `child_process`

I am trying to call a function in a python file from a js file, I got this to work through my console, but I am now trying to implement it in a mobile app using expo. The way I had set this up is, I have the JS file for a certain screen in my app,…
0
votes
1 answer

Cannot kill ChildProcess on Ubuntu

I am trying to kill the application in Ubuntu. I have the following code: import {ChildProcess, exec} from "child_process"; export default class VisiviTTS { private static process?: ChildProcess; public static speak(text: string): void { …
0
votes
1 answer

Create a persistent bash shell session in Node.js, know when commands finish, and read and modify sourced/exported variables

Imagine this contrived scenario: ./main.sh source ./config.sh SOME_CONFIG="${SOME_CONFIG}bar" ./output.sh ./config.sh export SOME_CONFIG='foo' ./output.sh echo "Config is: ${SOME_CONFIG}" I am trying to replace ./main.sh with a Node.js powered…
Molten Ice
  • 2,715
  • 1
  • 27
  • 37
0
votes
1 answer

run child_process to run server.js file

I'm getting a bit lost in child_process docs. What is the recommended way to run a server.js in a child_process ? Should I run this below? Also, if I kill the main file, will it kill the child process too? const { exec } =…
Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
0
votes
1 answer

How not to wait for finishing child process in Node.js?

actually I run my exec task in an async function. After execution a software starts and runs in a loop. After this execution, my node.js app stops going on with the code. How can I start running another app out of node.js and ignore the result and…
user3241084
  • 87
  • 1
  • 1
  • 11
0
votes
1 answer

Why children process is working with different command lines except tcpdump?

I don't understand why running the tcpdump program doesn't work but with other commands and programs it does, for example: Ping, openSSL, ... When I run it for example with Ping and OpenSSL, data appears in the console, but tcpdump does nothing, it…
stillborn1
  • 507
  • 1
  • 4
  • 10
0
votes
3 answers

BATCH: How can I close running batch file by the name using node.js

I want to know how can I close running batch file using Child process or anything in node.js This is an example for exec in child process const { exec, spawn } = require('child_process'); exec('my.bat', (err, stdout, stderr) => { if (err) { …
Miljte
  • 3
  • 1
0
votes
2 answers

Node.js run command line (child_process?)

I have a Node.js program where I need to, on a button click, run 2 commands in the Windows command line. For example, the process I'm trying to automate by the button click would be doable manually by going to cmd and entering the following…
mmarion
  • 859
  • 8
  • 20
0
votes
0 answers

passing .env vars to node child process

I'm trying to pass some env variables to a child process started using forever monitor, The problem is that I'm unable to load them from my custom .env file and pass to the child process. This is my index.js script #!/usr/bin/env…
newbiedev
  • 2,607
  • 3
  • 17
  • 65
0
votes
1 answer

How to execute commands in backend(Node.js Express) synchronously step by step?

I want to do this. But I am not able to run all of this synchronously. Every step is executing all at once. Can anyone help? I need to do this backend task in Node.js express. Step 1: Enter the keyword from the front end(written in react) Step 2:…
Sudip Bala
  • 13
  • 4
0
votes
1 answer

Detecting python exceptions in Node child_process

I've noticed that when I spawn a python script in Node.js using the child_process spawn() method, I can't catch exceptions. Here's a simple example to illustrate: index.js: const spawn = require('child_process').spawn; (() => { const py =…
Sean
  • 2,609
  • 1
  • 18
  • 34
0
votes
1 answer

BullMQ start Job from file with IIFE

Let's say I have a function1.js (or ts, it doesn't matter in this case),function2.js and any other files which are IIFE with different logic, like that: (async function F() { try { //[1,2,..n].map(x => console.log(x)); //await any other…
AlexZeDim
  • 3,520
  • 2
  • 28
  • 64
1 2 3
99
100