Waitforexit hangs

Waitforexit hangs

Author: spao Date: 23.06.2017

Tuesday, August 05, Process.

It's been over a year since the last time I blogged Sorry for that, but it's been a busy year. I've decided to pick up again and try to post some tech-related random thoughts once in a while.

Today I just wanted to share a bug I found that might be interesting for some of you. I had a small function that started a process and waited for it to finish it's work. The code looked something like this: To do this, I made sure that the RedirectStandardError properties of the process was set to true see code above , and inserted the following line to check if the application had encountered any errors: Close ; After this code had been used for a while, I noticed that once in a while the application was hanging when performing the above process.

c# - ProcessStartInfo hanging on "WaitForExit"? Why? - Stack Overflow

The problem only occured when a lot of data was written to standarderror. I debugged the problem, and found out that omitting reading from StandardError removed the problem.

waitforexit hangs

I thought that this seemed like a strange problem, and continued to search for a solution. After reading the documentation, I finally came up with the information that revealed the problem.

waitforexit hangs

The following remark in the msdn library for the RedirectStandardError property says: If a child process writes enough data to the pipe to fill the buffer, the child will block until the parent reads the data from the pipe. This can cause deadlock if your application is reading all output to standard error and standard output, for example, using the following C code.

ReadToEnd before calling WaitForExit solved the problem and made the solution a success. And make sure you read the remarks.

yvajotefihy.web.fc2.comrexit() not exiting

Posted by Christian F. Share to Twitter Share to Facebook Share to Pinterest.

c# - Visual Studio debug - yvajotefihy.web.fc2.coms hangs on WaitForExit - Stack Overflow

Newer Post Older Post Home. About Me Christian F. Can be reached at christian dot falch at gmail dot com View my complete profile.

inserted by FC2 system