Actually the title is a little misleading butthat is where the problem occurs. Those of you familiar with unix should know what I'm talking about.
Basically I'm using dup2() to redirect ouput meant for stdout to a file using the top command the problem is that the process hangs. I've guessed that top's not releasing the file descriptor once it's done (I'm passing it the instruction to dump just once into the file) but that's just a guess.
Now advanced unix-ers, please correct me if I'm wrong on this but with using the dup2() command I don't need to save the stdout file descriptor before I redirect it to the file which means when I'm done and I close it stdout should be returned to normal ops.
For those of you wanting to run the code, I attached it to my post in the networking board (should be on 1st page as it's recent)
Thanx for your time.