NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution
Questions tagged [nstask]
459 questions
6
votes
1 answer
How can you start a LaunchAgent for the first time without rebooting, when your code runs as a LaunchDaemon?
I have a LaunchDaemon. When it runs, it checks if SIMBL is installed. If SIMBL is not installed, it uses NSTask to run /usr/sbin/installer on the SIMBL.pkg.
SIMBL's postflight script then tries to run a launchctl load command to start SIMBL's…

jbrjake
- 174
- 1
- 8
6
votes
2 answers
NSTask blocking the main thread
I'm using NSTask, but when I launch the task it blocks the main thread (so I can't update it) until the task ends. This is my code:
NSString *hostsforping = @"google.es";
pingdata = [[NSTask alloc] init];
[pingdata setLaunchPath:…

pmerino
- 5,900
- 11
- 57
- 76
6
votes
1 answer
NSTask, command line tools and root
I'm working on an app that needs to use dd (I do this with a shell script in the app bundle, that collects parameters from the app itself, makes some checks and then launches dd).
To make this operation I need to call dd with root, and I already…

opoloko
- 347
- 5
- 13
6
votes
1 answer
How can I tell when a FileHandle has nothing left to be read?
I'm trying to use a Pipe's fileHandleForReading's readabilityHandler to read both the standardOutput and standardError of a Process. However, the moment the terminationHandler is called is actually before the moment my readabilityHandler is called…

Ky -
- 30,724
- 51
- 192
- 308
6
votes
2 answers
NSTask : Couldn't posix_spawn: error 13 when launching app
I have a sub-app in my main Swift app. I made it so it's copied automatically in the Resources folder of the main app when building it. That way, I want to be able to launch an instance of the sub-app from the main app.
The thing is, I'm having an…

Link14
- 896
- 1
- 15
- 33
6
votes
2 answers
cURL through NSTask not terminating if a pipe is present
I am trying to read the contents of a URL synchronously for a simple command-line batch script in Swift. I am using cURL for simplicity's sake - I know I could use NSURLSession if I had to. I am also building this with swift build using the…

tobygriffin
- 5,339
- 4
- 36
- 61
6
votes
3 answers
How to give permission using NSTask - objective-c
I need to basically do a "sudo" but, I need to give that kind of permission to my NSTask code. Is this possible?
Thanks,
Elijah

objectiveccoder001
- 2,981
- 10
- 48
- 72
6
votes
0 answers
NSTask from sandboxed helper app fails with "Could not set sandbox profile data"
I’m working on a Mac OS app composed of a main app and a helper :
Backup.app/
└── Contents
├── Library
│ └── LoginItems
│ └── BackupHelper.app
├── MacOS
│ └── Backup
Backup.app: ask the user to select a path and save…

Simon Watiau
- 637
- 5
- 17
6
votes
2 answers
How to work around NSTask calling -[NSString fileSystemRepresentation] for arguments
It seems that NSTask calls -[NSString fileSystemRepresentation] to encode values for each of the arguments you give it.
This can become a problem in some situations due to the fact that -fileSystemRepresentation encodes using decomposed unicode…

hasseg
- 6,787
- 37
- 41
6
votes
1 answer
Communication between process using NSPipe,NSTask
I need to realize a communication between two threads using NSPipe channels, the problem is that I don't need to call terminal command by specifying this methods.
[task setCurrentDirectoryPath:@"....."];
[task setArguments:];
I just need to write…

Andrew
- 885
- 1
- 10
- 15
6
votes
2 answers
NSTask/NSPipe read from Unix command
I am writing a Cocoa application which needs to execute a UNIX program and read its output, line by line, as they are produced. I set up a NSTask and NSPipe as such:
task = [[NSTask alloc] init];
pipe = [NSPipe pipe];
[task…

fmt
- 993
- 9
- 18
6
votes
1 answer
Controlling an interactive command-line utility from a Cocoa app - trouble with ptys
What I'm trying to do
My Cocoa app needs to run a bunch of command-line programs. Most of these are non-interactive, so I launch them with some command-line arguments, they do their thing, output something and quit. One of the programs is…

pmdj
- 22,018
- 3
- 52
- 103
5
votes
1 answer
Shell command via NSTask's Process delayed until my Vapor app quits
I built a Vapor 4 app that is currently deployed on a local Ubuntu 18 server VM, running behind NGINX and serving users without any issues.
Now I would like one of my web server routes to react to specific POSTs by executing a Bash command via…

cdf1982
- 764
- 1
- 18
- 34
5
votes
1 answer
Write to NSTasks standard input after launch
I am currently trying to wrap my head around the hole NSTask, NSPipe, NSFileHandle business. So I thought I write a little tool, which can compile and run C code. I also wanted to be able to redirect my stdout and stdin to a text view.
Here is what…

Janek
- 111
- 1
- 5
5
votes
2 answers
How to read all remaining output of readInBackgroundAndNotify after NSTask has ended?
I'm invoking various command line tools via NSTask. The tools may run for several seconds, and output text constantly to stdout. Eventually, the tool will terminate on its own. My app reads its output asynchronously with…

Thomas Tempelmann
- 11,045
- 8
- 74
- 149