javascript - nodejs child_processes.exec can not return 'nohup' command -


i write function of nodejs execute 'nohup' command , send success result http response.

function _nohup(cmd,res){     var child = exec('nohup ./' + cmd + '.sh &',     function (error, stdout, stderr) {         res.writeheader(200);         res.end("start process success!");     }); } 

but when call function url address, response data can not return.

child_process.exec() waits child process exit , invokes callback. in case, you've spawned background process, presumably isn't ever exiting.

you want child_process.spawn():

http://nodejs.org/docs/v0.4.9/api/child_processes.html#child_process.spawn


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -