Re: Redirecting Output for a fork()'d Process
Re: Redirecting Output for a fork()'d Process
- Subject: Re: Redirecting Output for a fork()'d Process
- From: Marc Epard <email@hidden>
- Date: Thu, 12 Apr 2007 11:23:35 -0500
You can set up file descriptors between the call to fork and the call
to execv. Since it's already in the child process, it doesn't do
anything to to the descriptors in the parent. MoreIsBetter has an
example:
<http://developer.apple.com/samplecode/QISA/listing38.html>
I've also read that you should close all unused file descriptors in
the child process so they don't leak information into the other
executable. After setting up std in/out/err, something like:
for (int i = STDERR_FILENO + 1; i < 1024; ++i)
close(i)
Except that there's a constant for 1024, but I'm not finding it at the
moment.
-Marc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden