Equivalent of ctrl c in command to cancel a program
Try:
kill -SIGINT processPIDHere
Basically Ctrl C sends the SIGINT
(interrupt) signal while kill sends the SIGTERM
(termination) signal by default unless you specify the signal to send.
If you control the long-running remote process, you could install a signal handler for SIGTERM (see man signal
and man sigaction
and the many SO questions on this topic), to cleanup nicely before dieing.
That is a very common thing to do.
Here's an example for mongod
To start the daemon from the command line:
mongod &
Then later
kill -SIGINT `pgrep mongod`
ctrl c just sends a SIGINT signal, but there is some other signals that is a little more soft. http://www.gnu.org/software/libtool/manual/libc/Termination-Signals.html
I think that you can use the the kill command to send some other signal. (see man kill for more info)