Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open fails in daemon



Am Mittwoch, 23.07.03, um 17:43 Uhr (Europe/Berlin) schrieb Matt Watson:

I use a modified sample from Apple. <http://developer.apple.com/qa/qa2001/qa1133.html>

Yikes. Bad sample code. We shouldn't be recommending daemon()...

I'm a bit confused about that daemon(), fork() and re-exec() thing.
But whats the right way?
deamon (0, 0);
execl (pathToApp, app, re-execHint, NULL);
_exit ();
or
fork ()
if child
execl (pathToApp, app, re-execHint, NULL);
_exit ();
if parent
exit ();

The first way seems to work. Is there an advantage for the second?
What about setsid ()?


childPID = vfork();

You want to use fork() here instead. Any library calls besides _exit or one of the exec*() family of functions result in undefined behavior after vfork().

agreed.


matt.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


--
Christian Weykopf
Meilenstein Mac OS Software

Neue Strasse 5
D-31582 Nienburg
Fax: +49 (0) 5021 91 24 45
<http://www.meilenstein.de/>
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: open fails in daemon (From: Matt Watson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.