0

I have a BAT program that repeatedly calls an EXE (MKS sed.exe) with output redirected to a TXT file. Sometimes termination of execution if this program by its window X button click leaves the EXE process running and the TXT file open for writing, obstructing further access to the TXT file.

Current workaround is: after clicking X, use Task Manager to manual terminate the EXE.

Is there a remedy not requiring replacement of the EXE?

I have no seen this problem from the same file on WinXP.

migrated from stackoverflow.com Jun 8 '13 at 16:52

This question came from our site for professional and enthusiast programmers.

  • Might be more reliable to terminate the process with CTRL-C, although you might have to change the batch file to check %ERRORLEVEL% to break out of the loop if sed.exe exits abnormally. It would probably help to include the contents of your batch file in the question. – Aya Jun 8 '13 at 13:12
  • 1
    You might have better luck getting answers to this question on SuperUser.com instead of StackOverflow. – dbenham Jun 8 '13 at 14:01
  • "Sometimes termination of execution if this program by its window X button click leaves the EXE process running" - Just to confirm, by "this program" you mean you're closing the command prompt window and terminating the batch file using the close button, and this leaves sed.exe running, correct? Well that is perfecly normal behaviour and I don't see how it wouldn't work exactly the same way in XP too. To detect forcible closure of the cmd prompt/batch window and perform cleanup i.e. kill other processes started by the script you'd need yet another monitor process, perhaps an AutoHotkey script. – Karan Jun 8 '13 at 21:44
  • "Might be more reliable to terminate the process with CTRL-C" I think it is. – ChrisJJ Jun 9 '13 at 22:40
  • "Just to confirm, by "this program" you mean you're closing the command prompt window and terminating the batch file using the close button, and this leaves sed.exe running, correct?" Correct " Well that is perfecly normal behaviour and I don't see how it wouldn't work exactly the same way in XP too." Interesting - thanks. I have not seen this problem on XP, but perhaps that is only luck. – ChrisJJ Jun 9 '13 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.