The book of inspiration

June 7, 2009

Stay hungry stay foolish

Filed under: life — Tags: — zproxy @ 7:20 pm

Life is too short not to do what you love to do…

  1. Steve Jobs dropped out of college only to drop in to interesting courses
  2. Steve Jobs got fired from Apple and found NeXT and Pixar
  3. Steve Jobs was diagnosed of cancer and was later cured

Program started via system diagnostics process hangs

Filed under: programming — Tags: , — zproxy @ 6:42 pm


The other day I was reading the standard output of another process I had created. If the output happened to be somewhat longer then the application would hang. I found that really odd and started to blame the external application at first, but after consulting to google™ I was told what I was doing it wrong. The compiler could of had warned be about the issue but it didn’t and I was left with a hanging application, which sucked. In short you have to make sure your StandardError stream wont pile up its precious buffer of 4096 bytes.

[…] you have a more general problem, which is the possibility that the standard output
will wind up blocked because you haven’t been reading from standard error.

In most cases, this may not be a problem, assuming the output to
standard error is brief. But it’s a basic issue with redirection of the
Process class standard i/o streams: if you redirect more than one, you
need to make sure you are using some form of asynchronous access to send
or receive data from all of them as appropriate. Otherwise, the console
application winds up blocked trying to read or write to one of the
streams, causing a form of deadlock.

The documentation for the Process class has a good, detailed explanation
of this. It’s helpful to read that if you intend to redirect the streams.


Learn something new each day… I guess one day google will be able to have a look at your problem and simply suggest the fix, but until then that remains as a manual feature.

Blog at