FAQ Database Discussion Community


How to kill a linux child_process.spawn using javascript?

javascript,linux,process,child-process,kill-process
var child_process = require('child_process'); if (typeof ffmpegrec == "undefined" || ffmpegrec == null) { var ffmpegrec = ''; } if(record === "1") { ffmpegrec = child_process.spawn("ffmpeg",[ "-re", // Real time mode "-f","x11grab", // Grab screen "-framerate","60", // Framerate "-s",width+"x"+height, // Capture size "-i",":"+screen+"+"+top+","+left, // Capture offset "-vb","1024k", // Target bit...

Redis data not showing up until Node.js child_process.fork() completes

node.js,redis,polling,child-process
I am forking a child process in a server app which does some repetitive CPU-bound work, a status value is pushed to Redis on every iteration. The problem is that the status value does not show up on Redis until the child process completes, so I am only able to...

Adding ffmpeg to heroku buildback nodejs

node.js,heroku,ffmpeg,child-process,buildpack
I've been trying to make a server that can visualize music (This is what I have so far). That's been successful but I want to try and make it work with youtube videos, and I've found a lot of repositories on github for youtube video to audio conversion that make...

nodejs child_process child process run twice

node.js,child-process
I want to connect a computer by the full computer name on Remote Desktop Connection. In nodejs, i create a child process to execute a cmd command.It executed successfully,but after two minutes, it execute again. I use the kill method of child_process module,it doesn't work. var child_process = require('child_process'); child_process.exec('mstsc...

Node js child process delete multiple files

javascript,node.js,child-process
I'm trying to set up a node.js child process to delete multiple files via the terminal. This works when deleting one file - but fails when I supply an array of files. const spawnSync = require('child_process').spawnSync; var toDelete = array.join(' '); if (toDelete.length) { spawnSync('rm', ['-rf', toDelete ]); } which...

Does nodejs create background task or child process to execute callback function

node.js,asynchronous,callback,background-process,child-process
Does NodeJS create a background task or child process to execute callback functions? How does NodeJS execute the query below? MyModel.find({}, function (err, docs) { //Do some thing }); ...

child_process.exec/spawn triggers callback/close with npm install command (via Gulp / Shipit)

node.js,promise,gulp,child-process
I'm using Shipit for deployment. On deploy, Shipit checks out the current Git Sha, to a tmp directory, then I run npm install followed by gulp build, then proceed with the deploy. Shipit uses Orchestrator for it's task flow, as Gulp does. Shipit has it's own CLI, so I...

Node.JS child processes being killed when parent dies

linux,node.js,child-process
I am using child_process.spawn() to start a script from my Node.JS application running on Ubuntu. As far as I know, standard forked or spawned *nix processes don't generally die when the parent dies, but when spawning processes from Node.JS, they seem to get killed when my application crashes, or is...

why does fork() return all possible outputs in this combination?

c,output,fork,child-process
Question: I need clarification/help on my understanding of fork() outputs. I know how to program more detailed and larger code in c with fork() and use other concepts like pipe, ipc, threads(posix). But my understanding with predicting return output is bad which is why I'm trying to figure this out...

Why cant I use char **myargs instead of char *myargs[3] while calling execvp()?

c,gcc,child-process,execvp
I have a C program to create a child process to run command "wc exec.c". Below is the program. /* Filename: exec.c*/ #include<stdio.h> #include<sys/wait.h> #include<unistd.h> #include<stdlib.h> #include<string.h> int main(int argc, char **argv) { printf("Hello world (pid = %d).\n",(int) getpid()); int ret = fork(); if (ret < 0) { fprintf(stderr,"fork failed.\n");...

nodejs child_process pass cmd args down to script

node.js,child-process,spawn
I use child_process.spawn to create a new process: child_process.spawn('node', ['app.js', 'x']); is there a way for me to get the cmd args(['app.js', 'x']) in app.js?...

Fork and execlp not executing my program?

c,fork,parent-child,pid,child-process
So I'm trying to create a child using fork and have that child run a program using execlp, only problem is that it isnt running... kind of. Heres my simple program else if (pid == 0) { fprintf(stderr,"Child process is accessing memory %d.\n", rand_num); execlp("helloworld", "helloworld", (char*)0); printf("hi\n"); exit(0); }...

How to execute / abort long running tasks in Node JS?

node.js,multithreading,mongodb,child-process,long-running-processes
NodeJS server with a Mongo DB - one feature will generate a report JSON file from the DB, which can take a while (60 seconds up - has to process hundreds of thousands of entries). We want to run this as a background task. We need to be able to...

Data loss in Node.js child process

javascript,regex,node.js,object,child-process
I'm trying to send data (as an object) to a child process in Node.js, however, all of my regular expressions get lost in transfer. var arguments = { something: { name: 'test', age: 28, active; true }, otherThing: 'some string', regex: /test/i, regex2: new RegExp('test') }; var child = cp.fork(path.join(__dirname,...

NodeJS child process stdout are all numbers

node.js,stdout,child-process
I'm writing some node.js scripts to kick off a child process. Code snippet is as below. var spawn = require('child_process').spawn; var child = spawn ('node', ['script.js']) child.stdout.on('data', function (data) { logger.verbose('tail output: ' + JSON.stringify(data)); } ); child.stderr.on('data', function (data) { logger.error('err data: ' + data); } ); Script runs...

NodeJS - How to pass a mysql connection from main to child process?

mysql,node.js,child-process
I tried the following server+worker code but it simply did not work. server.js: var net = require('net'); var mysql = require('mysql'); var cp = require('child_process'); var serverPort=20460; var connection = mysql.createConnection({ database : 'test', host : 'localhost', user : 'root', password : '' }); var server = net.createServer(function (socket){ socket.on('data',function(data){...

Advantages of node.js addon vs child_process

node.js,add-on,child-process
What would be the advantages, if any, of using a node.js addon written in C/C++ compared to calling a binary with arguments through child_process? More specifically, I have a small program, which accepts possibly up to a few hundred arguments and returns a boolean. ...

Multiple pipes and processes

c,operating-system,pipe,fork,child-process
I am trying to communicate with children processes and make them sort a part of a list. My problem is children processes read everything but do nothing after it. int main(int argc, char *argv[]){ int i; int num_children; pid_t pid; num_children= 3; int fd[num_children][2]; //PIPES for (i=0; i<num_children; i++) {...

Piping data from child to parent in nodejs

node.js,pipe,child-process
I have a nodejs parent process that starts up another nodejs child process. The child process executes some logic and then returns output to the parent. The output is large and I'm trying to use pipes to communicate, as suggested in documentation for child.send() method (which works fine BTW). I...

Javascript (node.js) capped number of child processes

javascript,node.js,max,child-process
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...