kill child process on restart of my windows service
Posted on 2011-05-10
I have created a windows service which fires another process (myprocess.exe) every 10 minutes, which creates files, prints them and exits. Sometimes when someone restarts the service while myprocess is still running, it does not kill the myprocess in the memory. The service starts another myprocess.exe, and now I see two instances of myprocess.exe in the task manager. Since both are trying to write to the same file, they clash and I get error.
How do I make my service kill myprocess.exe, if it is running when the service gets restarted.