Re: strange zombie NSTask which never completes on certain machines...
Re: strange zombie NSTask which never completes on certain machines...
- Subject: Re: strange zombie NSTask which never completes on certain machines...
- From: Tommy Nordgren <email@hidden>
- Date: Wed, 20 Dec 2006 00:32:47 +0100
On 20 dec 2006, at 00.15, Ryan Poling wrote:
I'm having a very strange problem with an NSTask in my project. I'm
launching it from an NSTimer at a set repeated interval which works
fine
on my PowerBook G4 (1.5 GHz). However, on an older G4 tower (400
MHz),
it starts working fine but then it always seems to hit a point
where the
task stalls and *never* terminates (after successfully working a few
times). The only way to get it to work properly is to keep track
of the
last time it worked successfully, and if it's been too long, manually
terminate the task and try again.
I have some code (see below) that the timer calls periodically. It
basically aborts the launching of the task if it thinks the task is
still running. But I run into this problem on the older G4 (and on
some
MacBook Pro's) where the [scannerTask isRunning] starts returning YES
all the time and then I never get to process anything..
- (void)doScan:(NSTimer*)theTimer {
[scannerPool release];
scannerPool = [[NSAutoreleasePool alloc] init];
if (scannerProcessing || [scannerTask isRunning]) {
// this is the manual termination and restart code
if (nil != lastScanAttempt) {
if (fabsf([lastScanAttempt timeIntervalSinceNow]) > (5.0 *
scannerRefreshRate)) {
[self stopScanning]; // also calls terminate on the NSTask
[self startScanning];
return;
}
}
return;
}
[lastScanAttempt release];
lastScanAttempt = [[NSDate date] retain];
// ... more code
}
This is very strange behavior. Any ideas what could cause this? I'd
like to get rid of the time check - it's kind of a hack.
Thanks.
-Ryan
External processes can block if you don't read from stdout and
stderr in a timely fashion,
and write to it's stdin when it expects.
The enclosed link is to the response of an earlier message of mine in
the context of Java
Apps. You can certainly use ideas to implement a Coco Solution.
http://lists.apple.com/archives/java-dev/2006/Jan/msg00269.html
------------------------------------------------------
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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