spawn

node.js child_process.spawn ENOENT error - only under supervisord

浪子不回头ぞ 提交于 2019-12-02 06:32:23
I'm running a command with Node.js using child_process.spawn: #!/usr/bin/js var spawn = require("child_process").spawn; var stockfish = spawn("stockfish"); This works fine using $js spawntest.js from the command line; it just hangs like you would expect because the subcommand is waiting for input. When I set this script up as a supervisord program, however, it fails: $ sudo supervisorctl start spawntest spawntest: ERROR (abnormal termination) Here is the contents of the stderror output log that supervisor keeps in /var/log/supervisor/spawntest-stderr---supervisor-RyULL0.log: events.js:72 throw

How do I obtain the PID of a spawned java process

大城市里の小女人 提交于 2019-12-02 02:16:36
I am writing several java programs and will need to kill off/clean up in a seperate JVM after I am done with whatever I wanted to do. For this, I will need to get the PID of the java process which I am creating. jps -l works both on Windows and Unix. You can invoke this command from your java program using Runtime.getRuntime().exec . Sample output of jps -l is as follows 9412 foo.bar.ClassName 9300 sun.tools.jps.Jps You might need to parse this and then check for the fully qualified name and then get the pid from the corresponding line. private static void executeJps() throws IOException {

Nodejs always cann't capture child process's stdout data completely, unless child process fllush(stdout)

流过昼夜 提交于 2019-12-02 00:30:21
I use nodejs to captured its child process's stdout data, but always captured the former part of child process's stdout data. When I add fllush(stdout) ,It works OK. But I don't know why, and don't want to add flush(stdout). Here is my code: var tail_child = spawn(exefile, [arg1, arg2, arg3]); tail_child.stdin.write('msg\n'); tail_child.stdout.on('data', function(data) { console.log(data); }); child_process.c printf("data\n"); Need your help! Thank you very much! By default, stdout in general is buffered until a newline is written. However, if stdout is not a tty (which is the case here with

Why does windows spawn process sometimes trigger error STATUS_SXS_ASSEMBLY_NOT_FOUND?

非 Y 不嫁゛ 提交于 2019-12-01 14:45:34
So, I have a tiny fragment of C code running on a windows box, that reads: /* invoke command */ impl->procHandle = _spawnve(_P_NOWAIT, command, vargs, env); if (impl->procHandle == -1) { printf("Failed to invoke command: %s\n", strerror(errno)); impl->busy = false; } printf("VICTORY\n"); I wrote some unit tests around this where my "command" was C:\windows\system32\ipconfig.exe and it works, no problem. Tried to use it for an application launcher... doo doo. Failed with the helpful error: The application failed to initialize properly (0xc0150004). Click on OK to terminate the application. Ok..

Why does windows spawn process sometimes trigger error STATUS_SXS_ASSEMBLY_NOT_FOUND?

假如想象 提交于 2019-12-01 12:42:18
问题 So, I have a tiny fragment of C code running on a windows box, that reads: /* invoke command */ impl->procHandle = _spawnve(_P_NOWAIT, command, vargs, env); if (impl->procHandle == -1) { printf("Failed to invoke command: %s\n", strerror(errno)); impl->busy = false; } printf("VICTORY\n"); I wrote some unit tests around this where my "command" was C:\windows\system32\ipconfig.exe and it works, no problem. Tried to use it for an application launcher... doo doo. Failed with the helpful error: The

Pipe output with expect spawn

放肆的年华 提交于 2019-12-01 10:52:09
I have script for copying some files by ssh to other server. I'm using tar for compressing files to on farchive and decompress it from stdout on other machine. set timeout -1 # user info set port [lindex $argv 0] set login [lindex $argv 1] set password [lindex $argv 3] set host [lindex $argv 2] #tar info set sdir [lindex $argv 4] set ddir [lindex $argv 5] spawn tar cf - $sdir | ssh -p $port $login@$host tar xf - -C $ddir expect "*?(yes/no)" { send "yes\r" } expect "*?assword" { send "$password\r" } expect "#" { send "ls $ddir -la\r" } expect "#" { send "exit\r" } interact But '|' doesn't work

Pipe output with expect spawn

对着背影说爱祢 提交于 2019-12-01 07:34:16
问题 I have script for copying some files by ssh to other server. I'm using tar for compressing files to on farchive and decompress it from stdout on other machine. set timeout -1 # user info set port [lindex $argv 0] set login [lindex $argv 1] set password [lindex $argv 3] set host [lindex $argv 2] #tar info set sdir [lindex $argv 4] set ddir [lindex $argv 5] spawn tar cf - $sdir | ssh -p $port $login@$host tar xf - -C $ddir expect "*?(yes/no)" { send "yes\r" } expect "*?assword" { send "

Indefinite daemonized process spawning in Python

拟墨画扇 提交于 2019-12-01 00:47:39
问题 I'm trying to build a Python daemon that launches other fully independent processes. The general idea is for a given shell command, poll every few seconds and ensure that exactly k instances of the command are running. We keep a directory of pidfiles, and when we poll we remove pidfiles whose pids are no longer running and start up (and make pidfiles for) however many processes we need to get to k of them. The child processes also need to be fully independent, so that if the parent process

Why is my Node child process that I created via spawn() hanging?

北城余情 提交于 2019-11-30 20:14:05
I am using spawn() to make a git call. Sometimes it works fine but others it appears to be hanging. I see no events firing (error, exit, close) yet I see evidence that the process did in fact complete successfully. var spawn = require('child_process').spawn; spawn('git', ['push', 'origin', 'master']) .on('error', function(error) { console.log("ERROR: DETAILS: " + error); }) .on('close', function(code) { console.log("SUCCESS: CODE: " + code); }) .on('exit', function(code) { console.log("EXIT: CODE: " + code); }) As it turns out once the stderr buffer exceeds 24kb you must be reading from it or

Grunt spawned process not capturing output

社会主义新天地 提交于 2019-11-30 17:27:54
I have spawned a process using Grunt, but nothing that is written to the output stream (such as console.log ) is being displayed in the console. I would like Grunt to display any output from the process. grunt.util.spawn( { cmd: 'node' , args: ['app.js'] , opts: { stdio: [ process.stdin , process.stout , process.stderr ] } }) Try setting it to opts: {stdio: 'inherit'} . Otherwise you can pipe the output: var child = grunt.util.spawn({ cmd: process.argv[0], // <- A better way to find the node binary args: ['app.js'] }); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); Or if