jhg543 / SendCtrlC

Windows console app for sending CTRL+C to external process.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SendCtrlC

This is an extremely simple Windows console application for sending a CTRL+C signal (SIGINT) to another process. This is something that is extremely tricky to do directly with the Win32 API, but is quite simple in a standalone helper process.

If the target process is cmd.exe, it guesses that it is a batch file and attempts to dismiss the "Terminate batch job?" prompt. It does this by sending 'y' to standard input, and is far from robust. In particular, it will likely fail on non-English versions of windows.

Usage

SendCtrlC <procesid>

Error Codes

Because the app works by connecting to the external process's console, it cannot print errors (or anything) to its own console. Errors are therefore communicated purely through error codes. Possible values are the follows:

 0: Success
 1: No process id specified
 2: Invalid process id (zero or non-numeric)
 3: Specified process id does not exist
 4: Specified process is not a console app
 5: Unknown AttachConsole error
 6: Failed to send CTRL+C signal to process

About

Windows console app for sending CTRL+C to external process.


Languages

Language:C++ 85.8%Language:C 14.2%