Nicolas Williams wrote: <snip>
> Ideally we'd have something like: > > /* > * Depending on flags daemon2() will fork(), setsid(), fork(), > * chdir("/"), etcetera. In the child daemon2() will call > * templace_callback(); if that returns non-zero, then daemon2() will > * exit(2) with that error. In the grandchild daemon2() will call > * init_callback(init_cb_data), and it that returns zero, then it will > * call context_setup(context_setup_data), and the grandparent will > * exit() with the first non-zero return value of those callbacks, else > * it will exit(0). (Internally daemon2() uses an IPC mechanism by > * which the grandchild communicates its status to the grandparent.) This is more generic version of the 2-phase/split daemonization approach outlined in: 5079306 contemplate a uu_daemonize_start()/_end() This seems to be the ideal approach in SMF world where the grandparent would only exit if an error occurred or the service is ready to do it's job. Given such thing does not exist yet, the man page can at most encourage the users of the function to process everything they could before calling it in order to foster the right behavior but this is already sort of present in the EXAMPLES section. v.