Alexander Barton alex@barton.de wrote:
Your approach won't work when using the REHASH command or sending the daemon a SIGHUP: ngIRCd forks a new process which possibly doesn't run with root privileges and/or chroot()'ed. The the pid-file can't be written.
# ps awux | grep ircd ircd 36023 0.0 0.1 2912 2580 ?? Ss Sun10AM 0:37.29 /usr/local/sbin/ngircd root 57004 0.0 0.0 1516 856 p0 RL+ 2:03PM 0:00.00 grep ircd # kill -HUP 36023 # ps awux | grep ircd ircd 36023 0.0 0.1 2912 2580 ?? Ss Sun10AM 0:37.31 /usr/local/sbin/ngircd root 57009 0.0 0.0 1516 692 p0 RL+ 2:04PM 0:00.00 grep ircd
It _DOES_ reread the config file, though (i changed the motd) I looked at the code... NGIRCd_SignalRestart is set to FALSE just at the beginning of the main loop int ngircd.c (around line 236 or so)... Hmmm... Why would you want it to fork()?
(everything is the same for /REHASH)
A possible solution should be (untested):
in main():
- open/create pid file with before dropping privileges
Yes, i thought about this. This would also eliminate the need to have a writeable file in the chroot. (So yes, I agree my patch is not optimal ;-) )
- unlink the file.
- call Write_Pidfile() inside the main loop.
- close the file before exiting.
I don't understand... Why would i need a pid file that i can't see from the outside of the process? (FreeBSD startup scripts would need a "permanent" pid in order to work properly i.e.:
# /usr/local/etc/rc.d/ngircd.sh status ngircd is running as pid 36023.
Thanks, Florian