• 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
NSTask / forking in sub-process / Problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask / forking in sub-process / Problem?


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

Again, I'm trying to figure this out by doing.

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.

  • Follow-Ups:
    • Re: NSTask / forking in sub-process / Problem?
      • From: "Steven M.Palm" <email@hidden>
  • Prev by Date: Adorning Pages
  • Next by Date: What the heck is going on here? :-)
  • Previous by thread: Adorning Pages
  • Next by thread: Re: NSTask / forking in sub-process / Problem?
  • Index(es):
    • Date
    • Thread