Link to home
Start Free TrialLog in
Avatar of patd1
patd1Flag for United States of America

asked on

kill child process on restart of my windows service

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.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of bartvd
bartvd
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patd1

ASKER

Thanks that was what I was thinking, but wanted to make sure if that is the right thing to do. Does it matter if I kill the myprocess onStop instead of onStart.

Thank You.
It doesn't matter, but make sure you kill the process before you start the new process.