javascript - How to give child process control of the terminal, in Node.js? -


i have node app run terminal (node myapp.js). app spawns child node process (via child_process.fork).

after happens, want exit parent process, , give child process control of terminal. right now, when exit parent, child process runs in background, , terminal goes bash. how can give terminal child process, doesn't go bash?

look @ child_process.spawn options.detached in node.js docs. looking for:

const spawn = require('child_process').spawn;  const child = spawn(process.argv[0], ['child_program.js'], {   detached: true,   stdio: ['ignore'] });  child.unref(); //causes parent's event loop not include child in reference count, allowing parent exit independently of child, unless there established ipc channel between child , parent. 

node provides child_process module has following 3 major ways create child process.

  • exec - child_process.exec method runs command in shell/console , buffers output.
  • spawn - child_process.spawn launches new process given command
  • fork - child_process.fork method special case of spawn() create child processes.

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -