• 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: launchd daemon, spawning children?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launchd daemon, spawning children?


  • Subject: Re: launchd daemon, spawning children?
  • From: Jason Coco <email@hidden>
  • Date: Thu, 25 Sep 2008 16:19:01 -0400


On Sep 25, 2008, at 16:12 , Mario Emmenlauer wrote:


Hi Terry,

thanks for the quick, and really extensive reply! Can you (or somebody)
point me to a good readme/technote/book on Mac OS standards? Searching
apple.com for posix_spawn() lists almost exclusively the manpages of the
functions, no more.



Terry Lambert wrote:
On Sep 25, 2008, at 9:50 AM, Mario Emmenlauer wrote:

2) I haven't tried pthread_start(), but its very likely to be equal

This should have been posix_spawn(), not pthread_start()... but come on,
they do sound similar :-D
posix_spawn() is morally equivalent to a vfork() followed by an execve(), with the ability to do a limited set of intermediate work in between.

Is this allowed behaviour for a launchd-daemon? From: http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html

I took:
[...] This includes calling the daemon function, calling fork followed
by exec, or calling fork followed by exit. [...]


and:
  [...] Do not close any stray file descriptors. [...]

The documentation is not consistent in disallowed behaviour. The
launchctl.plist manpage for example discourages calling fork()/exit()
only for the parent process (not for the child), and only because launchd
might assume it quit unexpectedly.

You can call fork/exec inside your launchd daemon, what the documentation is talking about is
backgrounding the daemon. That you're not allowed to do (i.e., fork/ exec then exit from the parent).
As long as the parent gets managed by launchd and stays around when it's supposed to, you
can spawn other processes. The second part of the documentation just notes that you shouldn't
close stray file descriptors... it's not really a conflict.


Jason

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

This email sent to email@hidden

References: 
 >launchd daemon, spawning children? (From: Mario Emmenlauer <email@hidden>)
 >Re: launchd daemon, spawning children? (From: Mario Emmenlauer <email@hidden>)
 >Re: launchd daemon, spawning children? (From: Terry Lambert <email@hidden>)
 >Re: launchd daemon, spawning children? (From: Mario Emmenlauer <email@hidden>)

  • Prev by Date: Re: launchd daemon, spawning children?
  • Next by Date: Re: launchd daemon, spawning children?
  • Previous by thread: Re: launchd daemon, spawning children?
  • Next by thread: Re: launchd daemon, spawning children?
  • Index(es):
    • Date
    • Thread