1

I'm using NSTask and NSPipe to execute a command and asynchronously get its output.

The code I'm using is almost 100% the same as in my question, here (with the fixes included).

However, while I'm testing it, I noticed that some times, the NSTaskDidTerminateNotification comes several milliseconds BEFORE the last NSFileHandleReadCompletionNotification.

In other words, the seemingly dead task is sending me data AFTER it has been terminated.

What's going wrong? Any ideas?

1
  • 1
    Nothing is wrong. If the pipe is only closed when the task ends, it is impossible to know which notification you will get first.
    – ughoavgfhw
    Apr 22, 2012 at 17:29

1 Answer 1

0

As @ughoavgfhw mentioned : it turns out there really was no issue.

1
  • Well, I found your question in the hopes to solve my problem - which is that I need to know how to wait until all the data has been read asynchronously after the task has terminated, because it so happens that there's stil some data to be read after termination of the task. Too bad your answer does not cover that Oct 18, 2019 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.