Placement of pclose
I'm wanting to open a stream with popen at the beginning of my app - do other things within the app, then close the stream. My question is:
Do I need to immediately pclose after popen or can I leave it open to keep collecting the stream while my app does other work?
You can leave it open. You only use pclose once you are ready to get the exit status and let the process terminate.
In future, you should probably direct questions about non-standard C function behaviour in an appropriate platform specific forum. In the case of popen/pclose, the Linux programming forum would be most appropriate.
Thanks for your response. Sorry, I'm new to C and I don't know what functions are specific to what platform.