Fixed Control-C race.
authorIain Patterson <me@iain.cx>
Mon, 28 Oct 2013 20:51:56 +0000 (20:51 +0000)
committerIain Patterson <me@iain.cx>
Mon, 28 Oct 2013 20:51:56 +0000 (20:51 +0000)
commita7ad3a9d294a66bb42bdbb068d620832182ea6b2
tree471de9710c48456e03347c2f602dd1220d27a39c
parentcb641f9b0c4a2987c8fb4fe4ff431ecb660a924f
Fixed Control-C race.

A typo in kill_console() could cause the application to be restarted
when it was supposed to stop.

When kill_console() successfully generated a Control-C event and the
application exited, the function was supposed to return 0, indicating to
its parent function kill_process() that the application had been killed.

Due to a mistake in the test of WaitForSingleObject()'s return code,
kill_console() would instead return non-zero when the application exited
in response to Control-C.  This would lead NSSM to continue with other
methods of trying to kill the application, leading to a race when
another thread detected that the application had exited without
recognising that it had done so in response to a stop control.

Thanks Barrett Lewis.
process.cpp