Send Interrupt signal (SIGINT
, aka Ctrl-C) to Windows process from Cygwin.
Cygwin will outright kill windows process instead of interrupting them, resulting in
improperly (or not at all) terminated processes, while the CMD shell works fine.
Prefixing some commands with cygint
can properly interrupt them.
This is a pretty basic, rough project as yet. Showing interest in improvements may make it a reality. Pull requests welcome.
- bash
Compiling
Building sendctrlc.cpp
will require Cygwin packages:
- g++
- mingw64
- make
Other compilers may work as well, YMMV.
make
Compiles sendctrlc.exe
in the current directory.
-
Add
sendctrl.exe
to your$PATH
(copy to~/bin
,/usr/local/bin
, etc, or update your PATH) e.g.echo 'PATH=$PATH:$LOCATION_OF_CYGINT' >> ~/.bashrc
-
Evaluate
cygint.bash
in your shell. Do this in your.bashrc
file for a more permanent install. e.g.:echo 'source $LOCATION_OF_CYGINT/cygint.bash' >> ~/.bashrc
Execute a target command in the shell, prefixed with cygint
, and it will
correctly respond to Ctrl-C.
$ cygint <command>
A Java test file is included. It uses a shutdown hook to print a message, which are notoriously not executed on Cygwin when using Ctrl-C.
(each invocation interrupted after 2s)
$> javac TestShutdownHooks.java
$> java TestShutdownHooks
0/20
1/20
$> cygint java TestShutdownHooks
0/20
1/20
Sending ctrl+c to: 286496
Hook called.
-
Stopping and Backgrounding are not supported: Jobs started with
cygint
cannot be backgrounded or stopped (vai Ctrl-Z). Attempting this will background the process controlling your target process, but the target will continue processing, and outputting to the console.You can use
fg
followed by Ctrl-C to interrupt the target if necessary. -
Error messages from target are being suppressed.
-
Very early project, and still has debugging output, so if it goes awry, it may pollute your console.