That looks reasonable for catching and displaying the system out and err character streams - now, are you seeing anything unexpected or getting any error codes?
Looking back at your original post:
When I run this .exe file continuosly.Say after executing 1000 times it hangs.
The following questions occur to me:
1. Are you waiting for the end of one Process before repeating or trying to fire off 1000 execs at one time?
2. Watching the task manager - does it show gradual increase in CPU utilization or is the change sudden? How about memory utilization/
3. This proces you are execing - what system resources does it use? File handles, Graphic contexts, DB connections, etc.
Bill