views:

308

answers:

3

I am invoking an external process by using System.Diagonistics.Process and passing two filenames as parameters. Now some time this process terminates due to exceptions and it seems that files handle are not being released by the process. How can i release the resources occupied by the process.

A: 

How are you detecting that file handles are not being released by the dying process?

All resources should be released by a process that dies for any reason. If they aren't, then it is a bug that should be filed with Microsoft.

How is that Microsoft's bug? The OP is starting a process external to his application that then subsequently terminates abnormally. If that process opened file handles then it's that processes responsibility to close them correctly.
Scott Dorman
The OS is responsible for closing any handles that remain open when a process terminates.
Michael Burr
+1  A: 

What is making you think that file handles are not being released? Since you are starting a process which is external to your application you don't have much control over what the other process is going to do when it terminates abnormally.

Scott Dorman
+1  A: 

This application is WMVAppend.exe (available with Microsoft Media SDK). Even when we restart the machines, it report the error dialogue and work fine for the next run. The issue with only media appending which is not done by our process. I also checked the source files and they seem perfect but they are not appended perfectly and files are not available to use.

Or It might be possible that process is not terminated at all, but i am using Process.WaitForExit() which should return only the process is terminated. The error dialog on restart suggests me this case could be possible.

Gripsoft