child-process

Cannot close/terminate child process in Netbeans

坚强是说给别人听的谎言 提交于 2019-12-12 03:04:39
问题 ANSWER in this previous question: https://stackoverflow.com/a/2035683/960086 It was not checked and quiet down, so I missed it. Already asked to be posted here I am playing around with an application that creates a socket connection on a child process. Now my problem is that trying to test it, but every time I run the application Netbeans creates main(Build, Run) and main(Run) when I close by clicking the red square or bottom right main(run) X button. The process "terminate" but it stays

Nodejs child_process spawn calling python script with sleep

烂漫一生 提交于 2019-12-12 00:26:47
问题 I'm testing on nodejs child_process module to read the stdout from my python script. However, I noticed when my python emit message between every second. The nodejs callback can only collect the stdout at the end of the python script ends. Python Script import time for i in range(0,5): ····print i ····time.sleep(0.5) and the nodejs script is var cp = require('child_process'); var spw = cp.spawn('python', ['tql.py']), str = ""; spw.stdout.on('data', function (data) { str+= data; console.log

sending crtl+c to a node.js spawned childprocess using stdin.write()?

自闭症网瘾萝莉.ら 提交于 2019-12-11 23:32:51
问题 In a node script, I have spawned a child process which executes a batch file run.bat , to terminate the program started by the batch-file i need to send ctrl+c combination to the child process , it is required for me to send ctrl+c combination to the program using stdin.write() method. var hmc = require('child_process').spawn('cmd'); hmc.stdin.write('run.bat \n'); 回答1: A CTRL + C is equivalent to sending a SIGINT on Windows. Rather than trying to send a keystroke to the process, you can send

Execute VBS from Nodejs in background mode (Tasks Scheduler or Windows Service)

亡梦爱人 提交于 2019-12-11 18:42:55
问题 I'm trying to convert an Excel File to PDF from a NodeJS App. It works when I start Node in command line, but when I start my app.bat as Windows Service through NSSM or directly with the Tasks Scheduler, it doesn't work anymore. With the script bellow, I can only see the first row in the log.txt which is the program arguments. If everything was going well, I should see 0, then 1, and 2. Sadly, when Node runs in background, I don't have any number, so i'm guessing the problem is CreateObject(

How to to run/close an http server as child process

不问归期 提交于 2019-12-11 17:13:38
问题 We have an application interacting with an (Node.js) HTTP server. To test the API calls, we have created a test HTTP server, which is working fine with the application. All the calls we make work as expected from the application. Recently, we have been spending time trying to automate the testing of these API calls. One strategy we came up with was to: start the test HTTP server automatically; make calls to it; close the test HTTP server after the test. Here is how our first test is written

Escaping double quotes in windows commands

旧时模样 提交于 2019-12-11 15:33:11
问题 I am trying to run a sample test using Jest to verify if my Google Cloud Function is working fine or not but I am constantly getting following error. Error: Command failed: gcloud beta functions call cf-1 --region europe-west1 --data '{"data":"eyJkYXRhIjoiMSJ9"}' ERROR: (gcloud.beta.functions.call) Invalid value for [--data]: Is not a valid JSON: No JSON object could be decoded I know that i can escape double quotes with backslash when running the command in windows terminal but how to do it

system() function while SIGCHLD is ignored

眉间皱痕 提交于 2019-12-11 09:54:45
问题 Here is an example piece of my code signal(SIGCHLD, SIG_IGN); ret = system("ls -al"); if(ret < 0) { perror("system failed"); printf("return value is %d\n", ret); } The ls -al command can be executed without any problem. But the return value of system() is always -1. In this case, I can't get the real return value of the command. Some reference says that ignore SIGCHLD would affect waitpid() in system() , that's why system always returns -1. But what puzzles me more is that: isn't SIGCHLD

Run a binary from Node.JS and relay the behavior exactly on the console, including prompts

穿精又带淫゛_ 提交于 2019-12-11 09:49:12
问题 I'm making a cli tool with Node.JS. I run another binary file from within node, and the other process asks for a password at some point. So what I need is to simply launch the other process, and put it "in charge" of the terminal, so the other process handles the prompts and the console output. 回答1: You can use 'inherit' for the stdio option of spawn: const spawn = require( 'child_process' ).spawn; spawn( '/path/to/binary', [], { stdio: 'inherit' } ); 来源: https://stackoverflow.com/questions

Unexpected end of file while reading mpstat output with BOOST ASIO async_read_until

前提是你 提交于 2019-12-11 07:58:42
问题 I try to read the output of mpstat command (collecting cpu information every second, ie: "mptstat -P ALL 1") in order to get information about cpu and core usage. On a multicore cpu, I get an unexpected "end of file" status just after having read the first measurements. It appears that mpstat formats its output in such a way that measurements for all cores are separated by an empty line. I have used async_read_until with a delimiter equal to '\n'. Please find below a small reproducer. With

Node.js child process with detached option

邮差的信 提交于 2019-12-11 07:54:30
问题 I am creating an electron desktop app, and I have code use spawn() with option detached: true. My purpose is to let the child process keep running even when the parent process terminated. const spawn = require('child_process').spawn; const ls = spawn('ls', ['-lh', '/usr'], { detached: true }); ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); fs.writeFileSync('path-to-test.txt', 'stdout'); }); ls.stderr.on('data', (data) => { console.log(`stderr: ${data}`); fs.writeFileSync(