Re: sharing file descriptors to an NSTask
Re: sharing file descriptors to an NSTask
- Subject: Re: sharing file descriptors to an NSTask
- From: Michael Ash <email@hidden>
- Date: Wed, 1 Sep 2010 12:09:20 -0400
On Wed, Sep 1, 2010 at 4:20 AM, Dave Keck <email@hidden> wrote:
>> descriptors are open. On OS X, you could read the contents of /dev/fd/
>> to accomplish the same thing. It appears that NSTask uses the uglier
>> getdbtablesize() loop though.
>
> Neat, I wasn't aware of /dev/fd. Are the necessary APIs
> async-signal-safe so they can be used between fork()/exec()?
Good question. I couldn't find a way to list the contents of that
directory using only safe APIs. You'd have to do it by execing a small
helper and then reading its output, which is terrible, or by execing a
small helper that can both close all open descriptors AND then exec
the thing you really want to exec. Unless there's some way to list the
contents of a directory that I couldn't find.
> Apparently getdbtablesize() isn't even documented as being so; in the
> strictest sense then, I guess you'd have to use you'd have to use
> INT_MAX. Hah.
I'm going to guess that the set of async signal safe calls is somewhat
larger than documented.... Should probably file a bug against NSTask
just in case, though. :)
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden