Yuck, so the parent has to write the pid file after fork(3)ing the child but before quitting ... ewww. . .
In other words, seperating the create from the check (and adding another "phony create" right after the check) will be necessary in order to avoid race conditions and to ensure that two copies of the daemon itself will never be running concurrently. (That is, the parent would have to check the pid file, then immediately create a pid file if none exists so another jabberd-parent doesn't also find no pid file existing if it's run before the fork in our jabberd-parent. After forking, our parent would then have to update the pid file with the child's PID, so the correct PID is in the pid file when the parent exits.) Dave Cohen <[EMAIL PROTECTED]> Ralph Siemsen wrote: > > Justin Georgeson wrote: > > I've been able rearrange some of the code in jabberd.c to get the port > > bound before setgid/setuid and fork. This lets me run jabberd on > > privileged ports as a nonroot user. The problem is the pidfile is still > > owned by root and has the wrong pid. Can anyone point me in the right > > direction? > > > > Cool, I was complaining about this not long ago. The create/check of > the pidfile happens in jabberd/config.c around line 161... but I'm sure > you already know that. I'll bet you're getting the parent's pid now? > I'm guessing the fork call got moved, right? So the pid is being > generated before the child process is forked. > > -R > > > _______________________________________________ > jdev mailing list > [EMAIL PROTECTED] > http://mailman.jabber.org/listinfo/jdev > _______________________________________________ jdev mailing list [EMAIL PROTECTED] http://mailman.jabber.org/listinfo/jdev
