On Apr 11, 2009, at 2:29 PM, Michael Domino wrote:
I ended up throwing out NSTask in favor of popen for running hdiutil, and my code seems much more stable now. Did I shoot myself in the foot some other way? I'm executing this in a pthread of its own. I also kept getting exceptions thrown for nil arguments to NSConreteTask, besides the problems getting the standard output either partially or not at all. This seems better:


FWIW, I was having some strange issues with NSTask and setuid child processes (not setuid root, mind you). I tried to peek at what NSTask was doing behind the scenes, and I found some rather confusing usages of CFFileDescriptor, kqueue(), and the like in the disassembly. My eventual solution was to roll my own version of NSTask which gave me full control over the way the child process was set up, from pre- fork() to to post-exec(). In particular, I use some of the lower-level UNIX calls directly (dup2()/close() instead of CFFileDescriptor, waitpid() on a separate thread instead of kqueue(), etc.). I was able to track down the issue I was having with the setuid process once I had the ability to trace the code running between fork() and execve().

The moral of the story is: Just because Apple provides a closed-source high-level Cocoa solution to a low-level UNIX problem, doesn't mean the Cocoa way is always the best.

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to