Questions tagged [nstask]

NSTask Class on OS X API , lets you run another program as a subprocess and monitor that program’s execution

452 questions
9
votes
0 answers

How to bundle AsciiDoctor gems in a Cocoa app

My app I have a Mac app that uses AsciiDoctor under the hood to generate PDF and ePUB files. I use the Process class (formerly NSTask) to run the AsciiDoctor commands. What I want I want people to be able to use my app without having to manually…
Mark Szymczyk
  • 17,064
  • 3
  • 51
  • 61
9
votes
2 answers

Xcode 8 extension executing NSTask

My goal is to create an extension that executes clang-format. My code looks something like this: - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable…
Guy Kogus
  • 6,960
  • 1
  • 23
  • 28
9
votes
1 answer

Run a terminal command in a Mac app with Swift Xcode

I am trying to run a terminal command in a Mac app that I am developing. The terminal command is: sudo sysctl -w net.inet.tcp.delayed_ack=0 I have tried using NSTask but it seems that I am doing something wrong every time. I just want to run this…
MRF
  • 385
  • 4
  • 10
9
votes
4 answers

Real time NSTask output to NSTextView with Swift

I'm using an NSTask to run rsync, and I'd like the status to show up in the text view of a scroll view inside a window. Right now I have this: let pipe = NSPipe() task2.standardOutput = pipe task2.launch() let data =…
The Beanstalk
  • 712
  • 5
  • 18
9
votes
1 answer

NSConcreteTask launchWithDictionary crash

I seem to get a lot of crash reports like this: Crashed Thread: 14 Exception Type: EXC_GUARD Exception Codes: 0x4000000200000000, 0x00007fff96f73c48 Thread 14 Crashed: 0 libsystem_kernel.dylib 0x00007fff97b7213a dup + 10 1 …
mwoods
  • 255
  • 2
  • 11
9
votes
5 answers

Ensure a subprocess is dead in Cocoa

I'm writing an application that kicks off a subprocess running a simple web server. I am using NSTask and communicating with it with pipes, and everything seems more or less fine. However, if my program crashes, the subprocess is left alive and the…
8
votes
2 answers

Using NSTask to execute ionic build commands - launch path not accessible

I'm working with Ionic which has a command line interface. I would like to create a small Mac app that helps to execute certain commands. In the terminal I cd Users/me/Desktop/Repos/ionic-project/myApp After changing I would e.g. ionic run NSTask…
brainray
  • 11,429
  • 10
  • 60
  • 109
8
votes
1 answer

NSTask launch path not accessible. Works in Xcode. Error shown out of XCode

Ok. There are several questions on stack overflow about this. This question was the only question comes closest to mines, but it uses notifications. The code is very simple. Create a new empty Mac OSX project and just paste the following code in the…
Just a coder
  • 10,809
  • 12
  • 70
  • 112
8
votes
1 answer

NSFileHandleDataAvailableNotification files repeatedly with no new data (resulting in very high CPU usage)

I'm attempting to read data from the Standard Error of a NSTask in Cocoa using waitForDataInBackgroundAndNotify. The following code does read the stream, so it's already working partially. The problem I have is that sometimes the…
Marco Aurélio
  • 2,363
  • 1
  • 19
  • 20
8
votes
1 answer

Interactive Shell Cocoa Application (NSTask)

I am trying to figure out how to pass input to a NSTask when prompted. Example: I do something like kinit username@DOMAIN and I get a "enter Password" prompt. I want to be able to supply the password to that NSTask. Does anyone know how to do…
user754905
  • 1,689
  • 2
  • 20
  • 29
7
votes
2 answers

NSUserScriptTask difficulties

I've been trying to make do (see this and this) with the recent NSUserScriptTask class and its subclasses and so far I've solved some problems, but some others remain to be solved. As you can see from the docs, NSUserScriptTask does not allow for…
Alex
  • 4,537
  • 3
  • 33
  • 68
7
votes
2 answers

Using NSTask and NSPipe causes 100% CPU usage

I'm trying to run a simple bash script using NSTask and direct the output to a text view. Once the task is executed, the CPU usage of my app is 100%, even though it's a simple echo (for now). I created a completely fresh project to isolate the…
DrummerB
  • 38,675
  • 12
  • 100
  • 138
6
votes
1 answer

How to embed an executable in my project

I would like to embed a command-line executable in my Xcode/Cocoa project, to then start it with NSTask. Which path should I use in the setLaunchPath ? Thanks !
Laurent Crivello
  • 3,403
  • 4
  • 37
  • 76
6
votes
4 answers

How to use a determinate NSProgressIndicator to check on the progress of NSTask? - Cocoa

What I have is NSTask running a long premade shell script and I want the NSProgressIndicator to check on how much is done. I've tried many things but just can't seem to get it to work. I know how to use it if the progress bar is indeterminate but i…
doctor_ew
  • 123
  • 2
  • 10
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,220
  • 10
  • 52
  • 75
1
2
3
30 31