Re: NSTask Open Word File

2016-08-12 Thread Jens Alfke
> On Aug 11, 2016, at 6:20 PM, Gurkan Erdogdu wrote: > > Hi folks > In my Swift application, I try to open a Word file with Microsoft Word > application via NSTask. To add to what Charles said: NSTask is only for running command-line tools or other non-GUI binaries. Don’t use it to run a GUI

Re: NSTask Open Word File

2016-08-11 Thread Charles Srstka
> On Aug 11, 2016, at 5:20 PM, Gurkan Erdogdu wrote: > > Hi folks > In my Swift application, I try to open a Word file with Microsoft Word > application via NSTask. Here is the code: > let task = NSTask() > task.launchPath = bundle!.executablePath >

Re: NSTask argument list

2016-06-26 Thread Graham Cox
> On 26 Jun 2016, at 4:58 PM, Sandor Szatmari > wrote: > > You can either asynchronously monitor the task's output with notifications, > or I have read about a new API, but never used it, > -setReadabilityHandler:^(NSFileHandle* file) > > Sandor > Thanks! I was able to set a readability

Re: NSTask argument list

2016-06-26 Thread Sandor Szatmari
Graham, > On Jun 26, 2016, at 01:29, Graham Cox wrote: > > >> On 26 Jun 2016, at 3:22 PM, dangerwillrobinsondan...@gmail.com wrote: >> >> If it helps, you can think of it as an object oriented wrapped around C >> system calls that keeps track of PID and all the other bits like stdout and >>

Re: NSTask argument list

2016-06-25 Thread Sandor Szatmari
Graham, > On Jun 25, 2016, at 23:37, Graham Cox wrote: > > HI all, > > I am using NSTask to wrap ffmpeg, the video conversion utility. > > I am able to invoke ffmpeg alright, but it’s unclear how the argument list > should be passed through NSTask. I tried making my various arguments into one

Re: NSTask argument list

2016-06-25 Thread Graham Cox
> On 26 Jun 2016, at 3:22 PM, dangerwillrobinsondan...@gmail.com wrote: > > If it helps, you can think of it as an object oriented wrapped around C > system calls that keeps track of PID and all the other bits like stdout and > so on. > That helps to grok why the args is and array and the too

Re: NSTask argument list

2016-06-25 Thread dangerwillrobinsondanger
If it helps, you can think of it as an object oriented wrapped around C system calls that keeps track of PID and all the other bits like stdout and so on. That helps to grok why the args is and array and the tool is separate. Sent from my iPhone > On Jun 26, 2016, at 1:37 PM, Graham Cox wrot

Re: NSTask argument list

2016-06-25 Thread Graham Cox
Ah thanks Marco, Andy… this makes a lot more sense and works fine. —Graham > On 26 Jun 2016, at 2:30 PM, Marco S Hyman wrote: > I believe arguments is an array of arguments, not an array containing a > string that matches a command line. > > Then your arguments array should contain five item

Re: NSTask argument list

2016-06-25 Thread Marco S Hyman
> > NSString* argString = [NSString stringWithFormat:@"-i \"%@\" -c copy > %@", [url absoluteString], [self.outputFileURL absoluteString]]; > > self.ffMPEGTask = [NSTask launchedTaskWithLaunchPath:execPath > arguments:@[argString]]; I believe arguments is an array of argument

Re: NSTask argument list

2016-06-25 Thread Andy Lee
Don't glom the arguments together.  Pass each as a separate array element: "-i", the URL string, "-c", "copy", the output string. And you don't need to quote the arguments, just pass them as is. I hope that makes sense -- I'd make it more code-like if I were at my desk rather than on my phone.

Re: NSTask & pseudo-TTY troubles

2015-03-01 Thread SevenBits
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/25/2015 04:15 PM, Kyle Sluder wrote: > On Wed, Feb 25, 2015, at 01:15 PM, SevenBits wrote: >> Here’s an example of the session when output is printed (notice >> the echoing): >> >> Insane BF Interactive Console 1.0 (Dec 18 2014, 16:22:05) Curren

Re: NSTask & pseudo-TTY troubles

2015-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2015, at 01:15 PM, SevenBits wrote: > Here’s an example of the session when output is printed (notice the > echoing): > > Insane BF Interactive Console 1.0 (Dec 18 2014, 16:22:05) > Current memory size: 3 cells, each 4 bytes > : , > , > A > A > > : > : . > . > A > : > > And h

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Thanks to everyone for helping !!! Using setEnvironment made it easily. I was looking for a complicated solution when the solution was not so difficult. Le 14 avr. 2014 à 17:59, Colas a écrit : > Thanks also for the idea of -setEnvironment. I will try.

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Unfortunately, it is not working. Gnuplot is complaining. ! Package pgfplots Error: Sorry, the gnuplot-result file ‘myFile.pgf-plot.t able' could not be found. Maybe you need to enable the shell-escape feature? Fo r pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplo t .g

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Bryan, I am trying to adapt your code to pdflatex. I hope it will work!!! It seems that putting the option -l at the end was very important. Do you know why? I have to admit that I put these « -c » and « -l » options thanks to other answers, but I don’t know what they are doing. Thanks very muc

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Le 14 avr. 2014 à 17:07, Bryan Vines a écrit : > Hi Colas, > > Pico is an interactive text editor. I don’t think NSTask is going to give you > much opportunity to interact with it. Are you using Pico as an example, or > are you actually trying to launch Pico? > > If you really *are* trying t

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, If my previous code snippet doesn’t work with pdflatex, NSTask has a -setEnvironment method; it may allow you to set your task’s environment variables. — Bryan Vines On Apr 14, 2014, at 10:40 AM, Colas wrote: > My problem is that I want to launch pdflatex with the -shell-escape optio

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Bash’s -c option expects commands in a string which follows. Therefore, this will work: I’m using /usr/bin/touch as an example, rather than your example of pico, which is an interactive text editor. NSTask * myTask = [[NSTask alloc]init]; NSArray * arguments = @[@"-c", @"/us

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
> Try putting > > /usr/bin/pico /Users/colas/myfile.txt > > into separate items in the argument NSArray. I find the man page ambiguous, > and I lack direct experience, but that may be what bash expects. > > It is not working, unfortunately. > I can’t guarantee that this will solve the large

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Ken Thomases
On Apr 14, 2014, at 10:08 AM, Colas B wrote: > Without the quotes, the error is > Error opening terminal: unknown. Terminal doesn't just run the shell (which, in turn, runs pico). It provides a window and a TTY (terminal device) for the processes to use and translates the I/O to the window. T

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Fritz Anderson
On 14 Apr 2014, at 10:08 AM, Colas B wrote: > OK. > > But without the simple quotes, it also fails. > > With the quotes, the error is > /bin/bash: pico /Users/colas/myfile.txt: No such file or directory > Without the quotes, the error is > Error opening terminal: unknown. > > Thanks! > Le Lund

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas B
OK. But without the simple quotes, it also fails. With the quotes, the error is /bin/bash: pico /Users/colas/myfile.txt: No such file or directory Without the quotes, the error is Error opening terminal: unknown. Thanks! Le Lundi 14 avril 2014 16h19, Jerry Krinock a écrit : From documentation

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Do you want your app to open a Terminal window, in which Pico has opened the file at /Users/colas/myfile.txt? If that’s so, I don’t think launching it via NSTask is going to get you anything. What is the end result you want to achieve? — Bryan Vines On Apr 14, 2014, at 8:59 AM, Colas B

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Jerry Krinock
From documentation of -[NSTask setArguments:] : "The strings in arguments do not undergo shell expansion, so you do not need to do special quoting” I don’t know what they mean by “special”, but anyhow, the ‘ ' you put around your last argument will be passed to your tool and cause it to fail.

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Keary Suska
ealize that this approach may be fragile in environments that you don't control (i.e. end-users). There also may be other variables needed... > Envoyé depuis Yahoo Mail pour iPad > > From: Keary Suska ; > To: Colas B ; > Cc: Cocoa-Dev (Apple) ; > Subject: Re: NSTask: pro

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Scott Ribe
On Apr 10, 2014, at 4:09 PM, Colas B wrote: > No, it is "Mach-O 64-bit executable" Then there is no shell run when you execute it via NSTask. Really, the correct answer is that pdflatex should not depend on a relative or hard-coded path for gnuplot. (It's fine of course to use such as a defaul

Re : Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Colas B
No, it is "Mach-O 64-bit executable" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Jens Alfke
On Apr 10, 2014, at 2:34 PM, Colas B wrote: > I don't specify explicitly a bash when I run my program (with NSTask) : I > just give the path to the program. It sounds like the program you’re telling NSTask to run is a shell-script. You can easily verify that by using the ‘file’ command (or j

Re : Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Colas B
I am not an unix-ey guy... I don't specify explicitly a bash when I run my program (with NSTask) : I just give the path to the program. If I discover the path to the shell being used, does it mean that what used to be the path of my NSTask will become an argument?About path and environment var

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Keary Suska
On Apr 10, 2014, at 2:52 PM, Colas B wrote: > Hi, > > thanks for your answers ! > Your idea sounds good. What can I do if I want both shells invoked from > programs and login shells to have the same initialization script? Shall I > write a new script that runs first ~/.login and then myprogram

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Jens Alfke
On Apr 10, 2014, at 1:52 PM, Colas B wrote: > Your idea sounds good. What can I do if I want both shells invoked from > programs and login shells to have the same initialization script? I think it’s better to make sure your login-shell setup script (.bash_profile or .login) doesn’t have thing

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Colas B
Hi,  thanks for your answers ! Your idea sounds good. What can I do if I want both shells invoked from programs and login shells to have the same initialization script? Shall I write a new script that runs first ~/.login and then myprogram ? Or is there a simplier way? In my case, myprogram is

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Jens Alfke
On Apr 10, 2014, at 6:23 AM, Keary Suska wrote: > This is more likely a shell scripting issue, rather than am NSTask issue, > unless sandboxing is somehow interfering, and you are obscuring the issue by > not telling us at least how myprogram is locating myauxprogram. The most > likely culpri

Re: NSTask: program launching another program, potential problem with path: how to do?

2014-04-10 Thread Keary Suska
On Apr 10, 2014, at 6:57 AM, Colas B wrote: > Dear cocoa-dev, > > I want to do with an `NSTask` what I am able to do in the terminal via > > $ myprogram myfile.ext > > I know that `myprogram` (I don't have any control on this program) launches > another program `myauxprogram`. Furthermore,

Re: NSTask for external tool - keep active/prevent relaunch?

2014-03-08 Thread Scott Ribe
On Mar 7, 2014, at 11:24 PM, Trygve Inda wrote: > The issue is that the > time spent launching the tool is vastly more then doing the tool's work... Are you sure about that??? Just because time is spent in the "launch" method doesn't prove that. You might want to sample (or spindump) everything

Re: NSTask for external tool - keep active/prevent relaunch?

2014-03-07 Thread Trygve Inda
> > On Mar 7, 2014, at 8:38 PM, Trygve Inda wrote: > >> I'd like it to work with md5, ffmpeg and others. These all work fine, but >> quit after returning their data. > > There’s nothing you can do about that, unless those tools allow multiple input > files to be passed on the command line. Chec

Re: NSTask for external tool - keep active/prevent relaunch?

2014-03-07 Thread Jens Alfke
On Mar 7, 2014, at 8:38 PM, Trygve Inda wrote: > I'd like it to work with md5, ffmpeg and others. These all work fine, but > quit after returning their data. There’s nothing you can do about that, unless those tools allow multiple input files to be passed on the command line. Check their man p

Re: NSTask for external tool - keep active/prevent relaunch?

2014-03-07 Thread Trygve Inda
>There is, but, first of all, why does this external tool terminate? > What is it? I'd like it to work with md5, ffmpeg and others. These all work fine, but quit after returning their data. T. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.co

Re: NSTask for external tool - keep active/prevent relaunch?

2014-03-07 Thread Jerry Krinock
On 2014 Mar 07, at 18:04, Trygve Inda wrote: > My app sometimes needs to call an external tool that runs via NSTask and > delivers text output back to my app. I profiled it and most of the time > (30%) is spent in [NSConcreteTask launchWithDictionary] > > Is there any technique I can use to kee

Re: NSTask and 10.9 [SOLVED]

2013-11-27 Thread Kyle Sluder
> On Nov 27, 2013, at 7:59 AM, koko wrote: > > NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"DeleteHidden" > ofType:nil]; > > NSTask *task; > task = [[NSTask alloc] init]; > [task setLaunchPath:scriptPath]; > > The script DeleteHidden had line endings of which caused an exc

Re: NSTask and 10.9 [SOLVED]

2013-11-27 Thread koko
NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"DeleteHidden" ofType:nil]; NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath:scriptPath]; The script DeleteHidden had line endings of which caused an exception on 10.9 removing the via a hex editor resolved the 10.

Re: NSTask and 10.9

2013-11-26 Thread Ken Thomases
On Nov 26, 2013, at 9:47 AM, koko wrote: > NSTask *task; > task = [[NSTask alloc] init]; > [task setLaunchPath:rootScriptPath]; > [task setArguments:[NSArray arrayWithObjects:rootpath, nil]]; > [task waitUntilExit]; > [task launch]; > [task release]; You have the invocation of -launch and -wai

Re: NSTask and 10.9

2013-11-26 Thread Kyle Sluder
On Tue, Nov 26, 2013, at 09:37 AM, koko wrote: > > On Nov 26, 2013, at 10:26 AM, Kyle Sluder wrote: > > > Error 2 is ENOENT. The path you passed to -setLaunchPath: does not exist. > > > > > Not possible as > > [task setLaunchPath:rootScriptPath]; > > where rootScriptPath is NSString *rootS

Re: NSTask and 10.9

2013-11-26 Thread Pax
So: NSFileManager *fileMgr = [NSFileManager defaultManager]; NSArray *contents = [fileMgr contentsOfDirectoryAtPath: error:nil]; for (NSString *item in contents) { if ([item rangeOfString:].location !=NSNotFound) { [

Re: NSTask and 10.9

2013-11-26 Thread Scott Ribe
On Nov 26, 2013, at 9:42 AM, koko wrote: > > On Nov 26, 2013, at 8:56 AM, Pax <45rpmli...@googlemail.com> wrote: > >> hy would you delete files in this manner? > > Need to wildcard the file names. Get the directory contents and look for matches, or use glob. -- Scott Ribe scott_r...@eleva

Re: NSTask and 10.9

2013-11-26 Thread koko
On Nov 26, 2013, at 8:56 AM, Pax <45rpmli...@googlemail.com> wrote: > hy would you delete files in this manner? Need to wildcard the file names. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator com

Re: NSTask and 10.9

2013-11-26 Thread Pax
Why would you delete files in this manner? It's more efficient to delete them directly from your Objective C code, thus: NSArray *fileArray = [@"path1",@"path2"]; for (NSString *filename in fileArray) { [fileMgr removeItemAtPath:filename error:NULL]; } You already know wh

Re: NSTask and 10.9

2013-11-26 Thread Kyle Sluder
On Tue, Nov 26, 2013, at 07:47 AM, koko wrote: > This works just fine up to and including 10.8.5 BUT throws an exception > at [task launch] on 10.9 What is the exception? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do

Re: NSTask interrupt exception

2013-07-25 Thread Martin Hewitson
Scott, Thanks for your detailed message. This lead me to search for -interrupt calls and I found one on another NSTask. I was assuming that this typesetting task was the issue, but maybe it's really this other task. My biggest problem is that I've never managed to reproduce the exception/crash

Re: NSTask interrupt exception

2013-07-25 Thread Scott Ribe
On Jul 25, 2013, at 8:24 AM, Martin Hewitson wrote: > Dear list, > > I have a couple of users reporting exceptions (and crashes) which I think are > associated with my interrupting an NSTask when they close a document. I get > exceptions like this: > > *** -[NSConcreteTask interrupt]: task no

Re: NSTask arguments

2013-02-20 Thread Ken Thomases
On Feb 20, 2013, at 10:31 PM, Kyle Sluder wrote: > On Feb 20, 2013, at 8:30 PM, Jens Alfke wrote: > >> On Feb 20, 2013, at 8:22 PM, Kyle Sluder wrote: >> >>> You can accomplish this without writing to the file system, but it >>> involves foregoing NSTask. Fork, close stdin in the child process

Re: NSTask arguments

2013-02-20 Thread Ken Thomases
On Feb 20, 2013, at 10:28 PM, Kyle Sluder wrote: > On Wed, Feb 20, 2013, at 08:22 PM, Kyle Sluder wrote: >> You can accomplish this without writing to the file system, but it >> involves foregoing NSTask. Fork, close stdin in the child process, open >> a pipe (so that the child gets the read end i

Re: NSTask arguments

2013-02-20 Thread Kyle Sluder
Oh crap, NOW I get it. :P You don't have to do the fork dance at all. Just call -setStandardInput: and pass /dev/stdin as the filename argument. Let NSTask take care of the rest. --Kyle Sluder On Wed, Feb 20, 2013, at 08:30 PM, Jens Alfke wrote: > > On Feb 20, 2013, at 8:22 PM, Kyle Sluder wro

Re: NSTask arguments

2013-02-20 Thread Kyle Sluder
On Feb 20, 2013, at 8:30 PM, Jens Alfke wrote: > > On Feb 20, 2013, at 8:22 PM, Kyle Sluder wrote: > >> You can accomplish this without writing to the file system, but it >> involves foregoing NSTask. Fork, close stdin in the child process, open >> a pipe (so that the child gets the read end i

Re: NSTask arguments

2013-02-20 Thread Jens Alfke
On Feb 20, 2013, at 8:22 PM, Kyle Sluder wrote: > You can accomplish this without writing to the file system, but it > involves foregoing NSTask. Fork, close stdin in the child process, open > a pipe (so that the child gets the read end in fd 0), then exec the tool > with "/dev/stdin" as the fil

Re: NSTask arguments

2013-02-20 Thread Kyle Sluder
On Wed, Feb 20, 2013, at 08:22 PM, Kyle Sluder wrote: > You can accomplish this without writing to the file system, but it > involves foregoing NSTask. Fork, close stdin in the child process, open > a pipe (so that the child gets the read end in fd 0), then exec the tool > with "/dev/stdin" as the

Re: NSTask arguments

2013-02-20 Thread dangerwillrobinsondanger
On 2013/02/21, at 13:11, Jens Alfke wrote: > > On Feb 20, 2013, at 4:18 PM, dangerwillrobinsondan...@gmail.com wrote: > >> Is there a way to feed an NSTask argument data when the command line tool in >> the task expects a file path argument? >> I would like to not actually create a file to u

Re: NSTask arguments

2013-02-20 Thread Kyle Sluder
On Wed, Feb 20, 2013, at 08:11 PM, Jens Alfke wrote: > You could conceivably create a fake volume in the filesystem that didn’t > correspond to any real file but just returned your data when read > (something like what the disk images driver does) … but the moment you > did this, your data would ex

Re: NSTask arguments

2013-02-20 Thread Jens Alfke
On Feb 20, 2013, at 4:18 PM, dangerwillrobinsondan...@gmail.com wrote: > Is there a way to feed an NSTask argument data when the command line tool in > the task expects a file path argument? > I would like to not actually create a file to use as the argument, but rather > send data that would b

Re: NSTask arguments

2013-02-20 Thread John Joyce
On Feb 21, 2013, at 9:46 AM, Greg Parker wrote: > On Feb 20, 2013, at 4:18 PM, dangerwillrobinsondan...@gmail.com wrote: >> Is there a way to feed an NSTask argument data when the command line tool in >> the task expects a file path argument? >> I would like to not actually create a file to use

Re: NSTask arguments

2013-02-20 Thread Greg Parker
On Feb 20, 2013, at 4:18 PM, dangerwillrobinsondan...@gmail.com wrote: > Is there a way to feed an NSTask argument data when the command line tool in > the task expects a file path argument? > I would like to not actually create a file to use as the argument, but rather > send data that would be

Re: NSTask Explodes. Clueless.

2013-02-07 Thread Seth Willits
On Feb 6, 2013, at 10:29 PM, Chris Hanson wrote: > On Feb 4, 2013, at 11:26 AM, Seth Willits wrote: > >> Looking around the open source code for exec(), it appears EINVAL (22) can >> be returned if the task was exec()'d when not called from a vfork()'d >> process, with the comment /* If we're

Re: NSTask Explodes. Clueless.

2013-02-07 Thread Ivan Ostres
On 2/4/13 8:26 PM, Seth Willits wrote: [snip] Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.Foundation0x978142d8 ___NEW_PROCESS_COULD_NOT_BE_EXECD___ + 7 1 com.apple.Foundation0x976d2e16 -[NSConcreteTask launchWithDictionary:] + 4698 2

Re: NSTask Explodes. Clueless.

2013-02-06 Thread Chris Hanson
On Feb 4, 2013, at 11:26 AM, Seth Willits wrote: > Looking around the open source code for exec(), it appears EINVAL (22) can be > returned if the task was exec()'d when not called from a vfork()'d process, > with the comment /* If we're not in vfork, don't permit a mutithreaded task > to exec

Re: NSTask Explodes. Clueless.

2013-02-06 Thread Chris Hanson
On Feb 5, 2013, at 10:39 AM, Seth Willits wrote: >> Does your crash log show multiple threads? I would expect that the crash log >> shows only one thread because NSTask called fork() already. > > Hmm. Yes, there's only one thread. I didn't notice that. That explains the > crash (of the forked

Re: NSTask Explodes. Clueless.

2013-02-05 Thread Seth Willits
> Does your crash log show multiple threads? I would expect that the crash log > shows only one thread because NSTask called fork() already. Hmm. Yes, there's only one thread. I didn't notice that. That explains the crash (of the forked process) "instead of an exception," like you mentioned. >

Re: NSTask Explodes. Clueless.

2013-02-05 Thread Greg Parker
On Feb 4, 2013, at 11:26 AM, Seth Willits wrote: > Exception Type: EXC_BREAKPOINT (SIGTRAP) > Exception Codes: 0x0002, 0x > > *** NSTask: Task create for path > '/Applications/App.app/Contents/Resources/mytask' failed: 22, "Invalid > argument". Terminating temporary

Re: NSTask: auxiliary executable does not see its data file

2012-08-01 Thread Jens Alfke
On Jul 30, 2012, at 8:08 AM, Daniel Stein wrote: > The tool tries to open the file with an ordinary call to fopen(): > f = fopen("my.data",READ_MODE); Of course this assumes the current directory is the one containing the my.data file. By default it won't be, because the tool inherits the curr

Re: NSTask and NSPipe has buffering issues?

2012-08-01 Thread Mr. Gecko
Thank you! That makes lots of sense and I was able to fix my code. I knew that I sometimes got zero length data, but never knew why. Now that I know it's the end of file… I can make lots of use of this knowledge. Thanks for the help. On Jul 31, 2012, at 11:20 PM, Ken Thomases wrote: > NSPipe

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Ken Thomases
NSPipe itself doesn't require that a run loop be run, but the "InBackgroundAndNotify" methods of the associated NSFileHandle objects do. You receive a zero-length NSData when (and only when) a read encounters EOF. There is an inherent race between the receipt of the task termination notificatio

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Jens Alfke
On Jul 31, 2012, at 7:43 PM, Mr. Gecko wrote: > I need threads because the main thread is a network loop waiting for a > connection and when it gets a connection, it spawns a thread like in my > example. I need to be able to respond to the client with all the data from > the task and I need t

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Mr. Gecko
I need threads because the main thread is a network loop waiting for a connection and when it gets a connection, it spawns a thread like in my example. I need to be able to respond to the client with all the data from the task and I need to close out the connection and release the spawned threa

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Kyle Sluder
On Jul 31, 2012, at 6:53 PM, "Mr. Gecko" wrote: > > I can confirm if you do not stop the run loop, it will get everything… > However… I cannot do this as I do not know how much data I am receiving from > the task. 1) Yes, you need to run the run loop forever (NSDistantFuture). 2) You don't n

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Mr. Gecko
I have multiple run loops. On the main thread I have [[NSRunLoop currentRunLoop] run]; On the sub threads for NSTask and NSPipe, I have CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES); If you are saying that you have to use NSRunLoop in order for it to work, get it working in my example and

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Kyle Sluder
On Tue, Jul 31, 2012, at 03:33 PM, Mr. Gecko wrote: > I am having weird results with NSTask. It sometimes retrieves the output, > and other times receives nothing. > > I have example code for this issue at > https://dl.dropbox.com/u/610721/NSTask%20Issue.zip NSTask requires a running runloop. You

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Mr. Gecko
What do you recommend after the task finishes? I have tried [[outPipe fileHandleForReading] readDataToEndOfFile] after the task finishes and it doesn't seem to improve. Can you maybe give me an example of how to do this right? On Jul 31, 2012, at 6:01 PM, Wim Lewis wrote: > I haven't looked a

Re: NSTask and NSPipe has buffering issues?

2012-07-31 Thread Wim Lewis
On 31 Jul 2012, at 3:33 PM, Mr. Gecko wrote: > I am having weird results with NSTask. It sometimes retrieves the output, and > other times receives nothing. I haven't looked at the code you posted, but is it possible that you're reading from the NSPipe in such a way that you're mixing up the "e

Re: NSTask terminates when NSApplication exits (Scott Ribe)

2012-01-20 Thread lpeng...@gmail.com
Re: NSTask terminates when NSApplication exits (Scott Ribe) Ling Peng 在 2012年1月19日,4:02,cocoa-dev-requ...@lists.apple.com 写道: > Re: NSTask terminates when NSApplication exits (Scott Ribe) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Ple

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Scott Ribe
On Jan 19, 2012, at 11:49 AM, Jens Alfke wrote: > Huh; you learn something new every day! Yeah, specifically I learned this about 6 months ago ;-) > In addition to shell behavior you mention, I also see this when Xcode crashes > and takes down the app I’m debugging. But I suppose Xcode configur

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Ken Thomases
On Jan 19, 2012, at 12:49 PM, Jens Alfke wrote: > On Jan 19, 2012, at 10:10 AM, Scott Ribe wrote: > >> Not true. It looks like the case at a cursory level because session >> management does this when you're in the terminal. There are various ways to >> arrange for a process to exit when its par

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Jens Alfke
On Jan 19, 2012, at 10:10 AM, Scott Ribe wrote: > Not true. It looks like the case at a cursory level because session > management does this when you're in the terminal. There are various ways to > arrange for a process to exit when its parent exits. But it is *not* the case > that a process i

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Scott Ribe
On Jan 18, 2012, at 1:38 PM, Jens Alfke wrote: > > Nope. In Unix, a process is killed when its parent process exits. Not true. It looks like the case at a cursory level because session management does this when you're in the terminal. There are various ways to arrange for a process to exit whe

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Keary Suska
On Jan 18, 2012, at 2:27 PM, Ken Thomases wrote: > On Jan 18, 2012, at 3:13 PM, Keary Suska wrote: > >> Any special handling of NSTask aside, Mac OS X uses Unix-based process >> control which closes all child processes when the parent is closed. > > No, that's not true. Where did you get that

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Kyle Sluder
On Wed, Jan 18, 2012 at 12:38 PM, Jens Alfke wrote: > Nope. In Unix, a process is killed when its parent process exits. No it's not. /tmp% cat processes.c #include #include int main(int argc, char **argv) { printf("Parent pid is %lu\n", (unsigned long)getpid()); pid_t child = fork();

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Jens Alfke
On Jan 18, 2012, at 10:59 AM, Andrew wrote: > I am trying to write a program that maintains different installs of > another program including launching the program. To do so, I am using > NSTask. Now when I quit my cocoa app. the NSTask app dies. … > According to what I have read, the applicatio

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Scott Ribe
On Jan 18, 2012, at 2:27 PM, Ken Thomases wrote: >> Note that you can't do this with Cocoa/Objective-C (at least Apple says you >> shouldn't…) > > You can fork() and exec() just fine. What you can't do is fork(), _not_ call > exec(), and then do anything other than call POSIX async-cancel-safe

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Andrew
Thanks, I'll have a look. BTW, I was able to confirm it is a result of streams. My Java processes do not quit if I pipe their output to null:  NSTask *task = [NSTask new];  [task setLaunchPath:execPath];  [task setCurrentDirectoryPath:_directory];  [task setArguments:arguments];  [task setStandard

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Ken Thomases
On Jan 18, 2012, at 3:13 PM, Keary Suska wrote: > Any special handling of NSTask aside, Mac OS X uses Unix-based process > control which closes all child processes when the parent is closed. No, that's not true. Where did you get that? Processes with a controlling terminal get a SIGHUP when th

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Keary Suska
On Jan 18, 2012, at 11:59 AM, Andrew wrote: > I am trying to write a program that maintains different installs of > another program including launching the program. To do so, I am using > NSTask. Now when I quit my cocoa app. the NSTask app dies. The task > that the NSTask is running is a Java pro

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Scott Ribe
On Jan 18, 2012, at 11:59 AM, Andrew wrote: > I can probably find out the answer by trying different things, but I'd > like to get a better insight for what is going on and why the child > task is terminating. You may want to try LS (Launch Services) routines. -- Scott Ribe scott_r...@eleva

Re: NSTask vmrun

2011-08-05 Thread Rainer Standke
Thanks, that's what I was missing. Rainer On Aug 5, 2011, at 20:21, Stephen J. Butler wrote: > On Fri, Aug 5, 2011 at 10:15 PM, Rainer Standke wrote: >> args: ( >>"-T fusion", >>"-gu Administrator", >>"-gp Admin", >>runScriptInGuest, >>"\"/Users/rainer/Documents/Virtual Mac

Re: NSTask vmrun

2011-08-05 Thread Stephen J. Butler
On Fri, Aug 5, 2011 at 10:15 PM, Rainer Standke wrote: > args: ( >    "-T fusion", >    "-gu Administrator", >    "-gp Admin", >    runScriptInGuest, >    "\"/Users/rainer/Documents/Virtual Machines.localized/Windows XP > Professional v1.vmwarevm/Windows XP Professional v1.vmx\"", >    "", >    "

Re: NSTask oddity with getting stdout

2011-07-30 Thread Ken Thomases
On Jul 26, 2011, at 11:22 PM, Scott Ribe wrote: > On Jul 26, 2011, at 5:52 PM, Shane Stanley wrote: > >> In Snow Leopard that worked fine; a notification would be sent when new data >> was written to the file. In Lion, as soon as it's called it goes into a >> loop; each time readInBackgroundAndNo

Re: NSTask oddity with getting stdout

2011-07-26 Thread Scott Ribe
On Jul 26, 2011, at 5:52 PM, Shane Stanley wrote: >> Maybe you should try to re-open your bug ;-) > > I did, but no reply. Too bad, since it seems to me the person who responded didn't know what they were talking about. > In Snow Leopard that worked fine; a notification would be sent when new

Re: NSTask oddity with getting stdout

2011-07-26 Thread Shane Stanley
On 27/7/11 3:18 AM, "Scott Ribe" wrote: > Maybe you should try to re-open your bug ;-) I did, but no reply. Here's some code that's reading a file that's being written periodically: -(void)dataFromFile:(NSNotification *)notif { NSData *data = [[notif userInfo] objectForKey:NSFileHandleNoti

Re: NSTask oddity with getting stdout

2011-07-26 Thread Scott Ribe
On Jul 26, 2011, at 12:18 AM, Shane Stanley wrote: >> On Jul 25, 2011, at 3:40 AM, Shane Stanley wrote: >> I wonder if they've changed how the readInBackgroundAndNotify works. >>> >>> Yes, they have. I logged a bug on it, and was told that the way it worked in >>> 10.6 was wrong -- whereas

Re: NSTask oddity with getting stdout

2011-07-25 Thread Shane Stanley
On 26/7/11 1:14 AM, "Scott Ribe" wrote: > On Jul 25, 2011, at 3:40 AM, Shane Stanley wrote: > >>> I wonder if they've changed how the readInBackgroundAndNotify works. >> >> Yes, they have. I logged a bug on it, and was told that the way it worked in >> 10.6 was wrong -- whereas it used not to s

Re: NSTask oddity with getting stdout

2011-07-25 Thread Scott Ribe
On Jul 25, 2011, at 3:40 AM, Shane Stanley wrote: >> I wonder if they've changed how the readInBackgroundAndNotify works. > > Yes, they have. I logged a bug on it, and was told that the way it worked in > 10.6 was wrong -- whereas it used not to send a notification until there was > something to

Re: NSTask oddity with getting stdout

2011-07-25 Thread Scott Ribe
On Jul 24, 2011, at 11:01 PM, Stephen J. Butler wrote: > That is, abandon processPipeClose and let each pipe handle its own > close in the notification when you're sure all of its read > notifications have actually been delivered. As you've presented it, > processPipeClose isn't needed. Your theo

Re: NSTask oddity with getting stdout

2011-07-25 Thread Shane Stanley
On 25/7/11 3:01 PM, "Stephen J. Butler" wrote: > I wonder if they've changed how the readInBackgroundAndNotify works. Yes, they have. I logged a bug on it, and was told that the way it worked in 10.6 was wrong -- whereas it used not to send a notification until there was something to read, it no

  1   2   3   4   >