Re: Weirdness in my PowerBook... Now reproducible
Re: Weirdness in my PowerBook... Now reproducible
- Subject: Re: Weirdness in my PowerBook... Now reproducible
- From: Jerry Krinock <email@hidden>
- Date: Wed, 05 Apr 2006 12:49:39 -0700
- Thread-topic: Weirdness in my PowerBook... Now reproducible
on 06/04/02 22:23, Michael Ash at email@hidden wrote:
> I am almost 100% sure that the problem is the
> following:
You're doing [task waitUntilExit] before you read the data out of
> the
task's output pipe. This is wrong and will fail exactly as
> you've
described....This is easily fixed
> by simply switching the order of the statements...
Thank you. Yes, I have now confirmed by experiment that indeed if the
stdout data exceeds about 4 KB, I get the deadlock as you described, and
indeed placing -readDataToEndOfFile before -waitUntilExit solves this
problem as you predicted.
> waitUntilExit] is entirely superfluous
For "ps", yes it is, but I left it in because I use this same wrapper for
other NSTasks which do not return any output.
But even after fixing this, I found that, with only 17 applications + 19
Terminal windows each running one useless process,
- new Terminal windows cannot initiate a shell
- Xcode will not compile:
error: couldn't run '/bin/sh' because an internal error
occurred (Resource temporarily unavailable)
- Activity Monitor crashes upon launch
- My application produces the Console output like this:
Exception raised during posting of notification.
Ignored. exception: couldn't fork
This is apparently because, as discussed in the first replies, we are
hitting the limit on the number of processes and/or user processes.
So there are TWO problems, and Michael gave me the solution to the first
one. Regarding the second one, I intercepted the "exception" using
NS_DURING. My NS_HANDLER informs the user of the process overload with an
NSCriticalAlertPanel and then quits the application.
Some advice to anyone else who might want to add this error recovery to
their NSTask wrapper:
- NS_DURING must be placed before -launch in order to catch the exception.
- It would be cool to put the task "return value" in the message to the
user, however sending -terminationStatus to the task invokes _another_ task
which also fails since it can't get resources either. So don't try that.
- Registering for notification NSTaskDidTerminateNotification does not work;
apparently the exception stops execution before the notification gets sent.
Thanks all for the help.
I'll submit Document Feedback to Apple, since I believe all these issues
should be discussed in "Interacting With The Operating System". There are
probably other dumb Cocoa programmers like me expect NSTasks to "just work".
Jerry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden