child-process

How to fork a process of another module

☆樱花仙子☆ 提交于 2019-12-10 15:19:53
问题 TL;DR : How does one fork a process that is located outside of the current running process? I'm trying to use child_process of Nodejs in order to start another nodejs process on the parent's process exit. I successfully executed the process with the exec but I need the child process be independent of the parent, so the parent can exit without waiting for the child, hence I tried using spawn with the detached: true, stdio: 'ignore' option and unref() ing the process: setting options.detached

Node.js child process to Python process

≡放荡痞女 提交于 2019-12-10 12:14:41
问题 I must send text from a node.js child process to a python process. My dummy node client looks like var resolve = require('path').resolve; var spawn = require('child_process').spawn; data = "lorem ipsum" var child = spawn('master.py', []); var res = ''; child.stdout.on('data', function (_data) { try { var data = Buffer.from(_data, 'utf-8').toString(); res += data; } catch (error) { console.error(error); } }); child.stdout.on('exit', function (_) { console.log("EXIT:", res); }); child.stdout.on

node.js child processes

荒凉一梦 提交于 2019-12-10 07:50:07
问题 I'm trying to figure out whether or not this would be a decent usecase for node.js child processes: I have a multiple player game where people are engaged into 1v1 matches. Should I use a child process for each match? 回答1: Not really needed. Since node is event based and a single process would be able to handle thousands of such player pairs. You would be creating "rooms"/"groups"/"channels" for each such pair, assuming that you are using now.js. The nomenclature may vary according to the

Python: How to determine subprocess children have all finished running

戏子无情 提交于 2019-12-09 06:20:28
问题 I am trying to detect when an installation program finishes executing from within a Python script. Specifically, the application is the Oracle 10gR2 Database. Currently I am using the subprocess module with Popen. Ideally, I would simply use the wait() method to wait for the installation to finish executing, however, the documented command actually spawns child processes to handle the actual installation. Here is some sample code of the failing code: import subprocess OUI_DATABASE_10GR2

how do I make node child_process exec continuously

自闭症网瘾萝莉.ら 提交于 2019-12-08 19:04:05
问题 How to exec continuously? e.g. ls after cd ? I tried exec = require('child_process').exec; exec('cd ~/', function(){ exec('ls'), function(err, stdout, stderr){ console.log(stdout); // this logs current dir but not ~/'s } } ) exec('cd ~/').exec('ls', function(err, stdout, stderr){ console.log(stdout); })//this also fails because first exec returns a ChildProcess Object but not itself. 回答1: It is not possible to do this because exec and spawn creates a new process. But there is a way to

Node / child_process throwing E2BIG

故事扮演 提交于 2019-12-08 15:55:24
问题 I have a fairly simple C++ program which only takes one argument that is a Base64 encoded string. I can call the program I am now trying to call this program using node's child_process.spawn() but it is throwing an "E2BIG" error when I pass in the same Base64 string. The Base64 string I am testing with is 305016 bytes in length. Running getconf ARG_MAX on my linux box returns 2097152 Any ideas why child_process throws the error? 来源: https://stackoverflow.com/questions/36251711/node-child

fork() and parent/child process ids

∥☆過路亽.° 提交于 2019-12-08 12:30:55
问题 I am a bit confused about why the child process in the following two programs is showing different parents ids. First program: int main ( void ) { int pid, fpid, ppid; fpid = fork (); pid = getpid(); ppid = getppid(); printf ("fpid is %d\n", fpid); sleep(5); if (fpid > 0){ printf ("\nThis is Parent. My pid %d. My parent's pid %d\n",pid,ppid); } else if (fpid ==0){ sleep(1); printf ("\nThis is Child. My pid %d. My parent's pid %d\n",pid,ppid); } else printf ("fork failed\n"); return (0); }

How to use parallel child processes to perform “work” on a large array?

自作多情 提交于 2019-12-08 06:05:12
问题 I have a huge array of numbers. I want to compute a sum of all of the numbers using JavaScript / Node.js. (For the purposes of this question it's a simple sum; in reality I have a much more complex and lengthy mathematical operation to perform). In a single-threaded world, computing the sum takes a long time. To crunch the result quicker, I've been trying to delegate the work to multiple child processes running in parallel. Each child process determines the sum of a sub-array, and everything

Why do multiple processes slow down?

流过昼夜 提交于 2019-12-08 03:53:09
问题 Not sure this is the best title for this question but here goes. Through python/Qt I started multiple processes of an executable. Each process is writing a large file (~20GB) to disk in chunks. I am finding that the first process to start is always the last to finish and continues on much, much longer than the other processes (despite having the same amount of data to write). Performance monitors show that the process is still using the expected amount of RAM (~1GB), but the disk activity

Javascript (node.js) capped number of child processes

浪尽此生 提交于 2019-12-07 22:38:57
问题 hopefully I can describe what I'm looking for clearly enough. Working with Node and Python. I'm trying to run a number of child processes (.py scripts, using child_process.exec()) in parallel, but no more than a specified number at a time (say, 2). I receive an unknown number of requests in batches (say this batch has 3 requests). I'd like to stop spawning processes until one of the current ones finishes. for (var i = 0; i < requests.length; i++) { //code that would ideally block execution