• 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: trying to control the output of a subprocess.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trying to control the output of a subprocess.


  • Subject: Re: trying to control the output of a subprocess.
  • From: Nicholaz Beresford <email@hidden>
  • Date: Fri, 05 Sep 2008 10:54:55 +0200


Greg,

thinking about it I'm sure you're right with this.


Nick



Greg Guerin wrote:
Nicholaz Beresford wrote:

Just guessing but if you can get a posix stream (FILE *)
you can try to use setbuf(stream, NULL);   Under posix
functions I'd do that after the fork() before exec()
but I have no idea how this works in Cocoa.

If you call setbuf() between fork() and exec(), it only affects the FILE* until the exec(), because a FILE* is the memory address of a FILE struct, not a heritable file-descriptor. Once the exec() occurs, the child process's memory is completely replaced by the new executable's code and data, and a completely new set of FILE*'s appears in the new executable. As a result, setbuf() is effectively not heritable, AFAIK.


Even if setbuf() were heritable, there is nothing to prevent the new executable from calling setbuf() again using its own buffer, thereby reversing the pre-exec() call to setbuf(). Many programs will, in fact, call setbuf() according to whether they detect the stdio streams being attached to a tty or not. Or they will do it in response to a particular command-line option.

Read 'man setbuf' and note what it says about line buffering and streams attached to terminals. That's why I think that a pseudo-tty is the main (or even only) way to do this, without having source to the command being exec()'ed.

  -- GG

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: trying to control the output of a subprocess. (From: Greg Guerin <email@hidden>)

  • Prev by Date: libsyncml / embed library in xcode
  • Next by Date: funambol-experiences, syncml
  • Previous by thread: Re: trying to control the output of a subprocess.
  • Next by thread: Re: Xcode + gdb problems with exec
  • Index(es):
    • Date
    • Thread