Starting and stopping CLI apps from a node application

52 views
Skip to first unread message

hammer

unread,
Apr 18, 2015, 12:15:06 PM4/18/15
to nod...@googlegroups.com
I have several CLI applications which are designed to shut down using cntrl-c which i would like to control using a node application (specifically a node-webmit app). Starting them is easy enough, but stopping them I'm not clear on. I thought maybe ncurses was the answer but all the information I can find about keyboard commands has to do with capturing them rather than sending them to an app. How can this be done in node?

Александр М.

unread,
Apr 19, 2015, 8:42:47 AM4/19/15
to nod...@googlegroups.com
Hello. If you send a signal SIGTERM, the application ignores it?

https://nodejs.org/api/child_process.html#child_process_child_kill_signal

Edin M

unread,
Apr 19, 2015, 8:42:51 AM4/19/15
to nod...@googlegroups.com
Have you tried child_process.kill


child.kill([signal])#
  • signal String
Send a signal to the child process. If no argument is given, the process will be sent 'SIGTERM'. See signal(7) for a list of available signals.

Oleg Verych

unread,
Apr 19, 2015, 8:43:13 AM4/19/15
to nod...@googlegroups.com
I have several CLI applications which are designed to shut down using cntrl-c which i would like to control using a node application

CTRL+C on TTY means that tty layer of kernel will send configured SIGNAL to the app, connected to that tty, i.e.

kill -INT `pid` 

Thus on start you should save pid of CLI app and then send signals to it or run `kill` program (or similar if not UNIX-like OS http://stackoverflow.com/questions/2214379/javascript-killing-a-process ).

nin jin

unread,
Apr 19, 2015, 8:43:13 AM4/19/15
to nod...@googlegroups.com

Francesco Cioffi

unread,
Apr 19, 2015, 8:43:29 AM4/19/15
to nod...@googlegroups.com
If you are on Linux you can use kill for send signal to process.


Il venerdì 17 aprile 2015, hammer <hamm...@gmail.com> ha scritto:
I have several CLI applications which are designed to shut down using cntrl-c which i would like to control using a node application (specifically a node-webmit app). Starting them is easy enough, but stopping them I'm not clear on. I thought maybe ncurses was the answer but all the information I can find about keyboard commands has to do with capturing them rather than sending them to an app. How can this be done in node?

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/fb27dbb5-720f-4429-9f79-367e38edd980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Inviato da Gmail Mobile

Ryan Schmidt

unread,
Apr 19, 2015, 8:43:36 AM4/19/15
to nod...@googlegroups.com

On Apr 17, 2015, at 3:16 PM, hammer wrote:

> I have several CLI applications which are designed to shut down using cntrl-c which i would like to control using a node application (specifically a node-webmit app). Starting them is easy enough, but stopping them I'm not clear on. I thought maybe ncurses was the answer but all the information I can find about keyboard commands has to do with capturing them rather than sending them to an app. How can this be done in node?

Control-C is the usual way to terminate a program interactively, but the way to terminate a program programmatically is usually to send it a signal like SIGINT. Does that work for these programs you're trying to control?


Reply all
Reply to author
Forward
0 new messages