A customer discovered a bug where terminating a process did not close the handles that the process had open, resulting in their emergency cleanup code not working:
TerminateProcess(processHandle, EXITCODE_TERMINATED);
DeleteFile(someFile);
Their workaround was to insert a call to WaitForSingleObject(processHandle, 500) before deleting the file. The customer wanted to know whether they discovered a bug in TerminateProcess, and they were concerned that their workaround could add up to a half second to their cleanup code, during which the end user is sitting there waiting for everything to clean up.
As MSDN notes,
TerminateProcess initiates termination and returns immediately. This stops execution of all threads within the process and requests cancellation of all pending I/O. The terminated process cannot exit until all pending I/O has been completed or canceled.
(Emphasis mine.)
Read more: The old new thing
QR:
QR:
0 comments:
Post a Comment