Don't try to notify about task termination on the thread that started the task

if it has already finished executing.
This commit is contained in:
Richard Frith-Macdonald 2018-01-15 11:42:04 +00:00
parent 5bdcd3c698
commit 28048a5947
3 changed files with 7 additions and 8 deletions

View file

@ -2,6 +2,8 @@
* Source/NSThread.m: Improve exception message when performing a
selector on a finished thread.
* Source/NSTask.m: Do not try to notify task completion on a thread
that is not executing.
* configure.ac: Fix for older versions of pkg-config
* configure: regenerate

View file

@ -414,11 +414,7 @@ pty_slave(const char* name)
*/
- (void) launch
{
if (_launchingThread != [NSThread currentThread])
{
[_launchingThread release];
_launchingThread = [[NSThread currentThread] retain];
}
ASSIGN(_launchingThread, [NSThread currentThread]);
}
/**
@ -937,7 +933,7 @@ pty_slave(const char* name)
if (_hasNotified == NO)
{
_hasNotified = YES;
if (_launchingThread != nil)
if ([_launchingThread isExecuting] == YES)
{
[self performSelector: @selector(_notifyOfTermination)
onThread: _launchingThread

View file

@ -1690,9 +1690,10 @@ GSRunLoopInfoForThread(NSThread *aThread)
if ([aThread isFinished] == YES)
{
[NSException raise: NSInternalInconsistencyException
format: @"perform [%@-%@] attempted on finished thread",
format: @"perform [%@-%@] attempted on finished thread (%@)",
NSStringFromClass([self class]),
NSStringFromSelector(aSelector)];
NSStringFromSelector(aSelector),
aThread];
}
if (aFlag == YES)
{