[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with NSTaskDidTerminateNotification
From: |
Richard Frith-Macdonald |
Subject: |
Re: Problem with NSTaskDidTerminateNotification |
Date: |
Sat, 5 Apr 2014 08:54:08 +0100 |
On 5 Apr 2014, at 07:50, Germán Arias <address@hidden> wrote:
> On PC if you build a tool that writes more than one line. for example:
>
> NSLog(@"One");
> NSLog(@"Two");
> NSLog(@"Three");
>
> And run this at launch panel, only the first line is printed. The problem is
> that NSTaskDidTerminateNotification is sent after print the first line, even
> when Task is still running.
That seems to require a major bug in windows (since the notification is sent
only after windows says the process has terminated).
More likely something's messing with the output. If you are reading the output
of the task via a pipe, most like the sequence of events is:
1. subtask writes three lines to pipe
2. parent reads first line and prints it
3. subtask terminates
4. parent receives notification and closes pipe without reading remaining two
lines
But I expect there are other possible ways that you could lose buffered output
when a task ends; I suggest you examine the I/O you are doing.
Another possibility would be if you are launching an intermediate subtask (eg a
shell which then runs the tool asynchronously) which terminates.
1. launch the shell subtask
2. shell launches the tool
3. shell terminates
4. parent receives notification
5. tool terminates