• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask / forking in sub-process / Problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask / forking in sub-process / Problem?


  • Subject: Re: NSTask / forking in sub-process / Problem?
  • From: "Steven M.Palm" <email@hidden>
  • Date: Sun, 9 Mar 2003 22:04:07 -0600

For the archives...

It turned out that I needed to specify in the NSTask environment an updated PATH environment variable that included the directory for the bundle resources where the second spawned task executable lives. Then, all was pretty much ok.

On Sunday, March 9, 2003, at 11:57 AM, Steven M.Palm wrote:
I have a command line program that works great. I'm trying to wrap it in a Cocoa gui, and am using an NSTask to launch it, and then watching the stdin/stdout to interact. I've followed the stuff in Chapter 24 of Cocoa Programming pretty closely, and based my code off the samples there.

The problem is that the program I launch via NSTask then forks off it's own subprocess like so:

if((pipe(audioInPipe)== 0) && (pipe(audioOutPipe) == 0)){
fprintf(stderr, "Audiopipes %d and %d\n", audioInPipe, audioOutPipe);
audioPid = fork();
if(audioPid == 0){

close(STDIN_FILENO);
dup(audioOutPipe[0]);
close(audioOutPipe[1]);
close(audioOutPipe[0]);
close(STDOUT_FILENO);
dup(audioInPipe[1]);
close(audioInPipe[1]);
close(audioInPipe[0]);

execlp("echoaudio", "echoaudio", remoteNode, callsign, 0);
}
}
else{
perror("pipe");
exit(1);
}

close(audioInPipe[1]);
close(audioOutPipe[0]);

audioOutFd = fdopen(audioOutPipe[1], "w");
if(!audioOutFd){
perror("fdopen (audioOutPipe)");
exit(1);
}

And while this works great when run from a command line, it fails on the fdopen() call when run from the NSTask.

Can anyone help????

-----------------------
- Steven M. Palm
- Ham Radio Call: N9YTY
- Attempts to make thine own star shine shall lead thee into darkness.
-----------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


-----------------------
- Steven M. Palm
- Ham Radio Call: N9YTY
- Attempts to make thine own star shine shall lead thee into darkness.
-----------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSTask / forking in sub-process / Problem? (From: "Steven M.Palm" <email@hidden>)

  • Prev by Date: RE: Threaded data freaking out
  • Next by Date: Need guidance in table sorting
  • Previous by thread: NSTask / forking in sub-process / Problem?
  • Next by thread: What the heck is going on here? :-)
  • Index(es):
    • Date
    • Thread