Questions tagged [nspipe]

34 questions
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
  • 39,814
  • 12
  • 105
  • 142
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
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
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
5
votes
2 answers

Calling Gnuplot in Swift

I'm trying to call gunplot from swift to produce some plots in .png. However, the program below does not work --- the resulting 1.png file is empty. If I leave the "set term aqua" though, it does call the aqua window with the plot in it. However…
Yrogirg
  • 2,301
  • 3
  • 22
  • 33
3
votes
0 answers

NSTask does not receive stdout outside of Xcode 4.3.3

this is my first post, so let me send me many thanks to all the posting guys outside there (I use SO extensively passively - great!) I'm working on an video exporting tool for Mac OS X using the good old Quicktime API. Brief: I cut frames from…
Mat Col
  • 31
  • 2
3
votes
2 answers

NSTask with multiple pipe input

I'm trying to use pipes to handle a command that requires multiple inputs, but not quite sure how to do it. Here's a snippet of what I'm trying to do. I know how to handle the first input, but I'm at lost as to piping in the second input…
Daniel
  • 648
  • 1
  • 8
  • 14
2
votes
1 answer

Using NSPipe for interactive commands

I'm launching some interactive process inside my OS X app I want to be able to read and write from pipes. For example: Launching the process will wait for user to type command. When user is finished (aka pressed enter), process will return something…
markich
  • 356
  • 4
  • 10
2
votes
1 answer

Communication between Cocoa App and console app

I have two applications, one with UI (a Cocoa app). The other being a console app. My requirement is to take user input in CocoaApp and pass it to process to ConsoleApp and return the value. I have tried something like this, I am able to send and…
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
2
votes
1 answer

How to use NSTask run terminal commands in loop in consistent environment?

I want to use NSTask to simulate the Terminal to run commands. The codes as follows. It can get input in loop and return the process output. int main(int argc, const char * argv[]) { @autoreleasepool { while (1) { char str[80] =…
Tom Jacky
  • 203
  • 1
  • 7
  • 20
1
vote
1 answer

Interactive access to command using NSTask

I am using an NSTask to run a cli app that in interactive. Im using it to pull data over a USB connection. I am opening an NSTask with an outline and error pipe but when I issue a command, it works, but spins the beach ball in the loop pulling data…
JeremyLaurenson
  • 979
  • 2
  • 11
  • 23
1
vote
1 answer

How to "tee" NSPipe in Swift

I'm trying to tee the standard output NSPipe one of NSTask to get two NSPipes, each of which will go into the standard input of two new NSTasks. I know I can do this in C with the tee function, but I couldn't find it in neither the Foundation nor…
Alexander
  • 59,041
  • 12
  • 98
  • 151
1
vote
1 answer

How to test that no data is written to an NSPipe

I've been working on a logging framework as of recent, and I'm allowing the user to provide an NSPipe for the logs to go down if they don't want the log messages to go to the console. The Logger can be enabled or disabled, and when disabled, should…
max_
  • 24,076
  • 39
  • 122
  • 211
1
vote
0 answers

NSPipe doesn't return all data

I'm struggling with this one for a quite of time. I'm communicating with other program using NSPipe, and everything works fine except when I get notification NSFileHandleDataAvailableNotification, I don't get all data available. So far I figured it…
markich
  • 356
  • 4
  • 10
1
2 3