title: Run arbitrary subprocesses on Windows and still terminate cleanly?
body: <p>I have an application A that I would like to be able to invoke arbitrary other processes as specified by a user in a configuration file.</p>
  
  <p>Batch script B is one such process a user would like to be invoked by A. B sets up some environment variables, shows some messages and invokes a compiler C to do some work.</p>
  
  <p>Does Windows provide a standard way for arbitrary processes to be terminated cleanly? Suppose A is run in a console and receives a CTRL+C. Can it pass this on to B and C? Suppose A runs in a window and the user tries to close the window, can it cancel B and C?</p>
  
  <p>TerminateProcess is an option, but not a very good one. If A uses TerminateProcess on B, C keeps running. This could cause nasty problems if C is long-running, since we might start another instance of C to operate on the same files while the first instance of C is still secretly at work. In addition, TerminateProcess doesn't result in a clean exit.</p>
  
  <p>GenerateConsoleCtrlEvent sounds nice, and might work when everything's running in a console, but the documentation says that you can only send CTRL+C to your own console, and so wouldn't help if A were running in a window.</p>
  
  <p>Is there any equivalent to SIGINT on Windows? I would love to find an article like this one: <a href="http://www.cons.org/cracauer/sigint.html" rel="noreferrer">http://www.cons.org/cracauer/sigint.html</a> for Windows.</p>