Reputation: 8699
I'm executing a shell script using NSTask but the problem is that the shell script is one of those scripts that keeps running until you press control+c. It starts up fine but then my mac application just waits for it to end. How can I make it so that it detaches the task from the mac application and goes and runs it in a background.
Upvotes: 3
Views: 1169
Reputation: 162712
Don't call waitUntilExit
or otherwise run the task synchronously. If the task has lots of output, make sure you read and process the data or else an i/o buffer will fill and it'll block.
In general, you shouldn't be using NSTask for a daemon like operation anyway. You should be using launchd.
Upvotes: 2