NSTask -launch fails sheepishly when ARG_MAX exceeded
NSTask -launch fails sheepishly when ARG_MAX exceeded
- Subject: NSTask -launch fails sheepishly when ARG_MAX exceeded
- From: "email@hidden" <email@hidden>
- Date: Thu, 20 Jan 2011 22:39:30 +0000
The docs for NSTask -launch state:
Raises an NSInvalidArgumentException if the launch path has not been set or is invalid or if it fails to create a process.
What it doesn't address is what happens if the process command line formed from the NSTask properties exceeds ARG_MAX.
The path is valid, the process is created but the process subsequently becomes invalid.
In this case the exec() that follows the fork() fails as ARG_MAX is the limit for exec() arguments.
The child process now has no raison d'etre and expires declaring:
*** NSTask: Task create for path '/some/crumbs' failed: 22, "Invalid argument". Terminating temporary process.
The parent process receives the above on the child's stdErr.
No exception is raised in the parent.
NSTask -terminationStatus returns 5.
What is the best way to detect this failure so that an intelligible error can be reported to the user who instigated the task (eg "the task you submitted was really just too big")?
I can grep the stdErr report, but it's hardly a robust approach, or is the terminationStatus wholly distinctive or documented?
Or I could estimate how close the process command line resulting from the NSTask is to ARG_MAX (256 * 1024) and take avoiding action.
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com
_______________________________________________
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