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 (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to