Touch PID file on SIGHUP to ACK signal
When used with Finit a daemon is expected to acknowledge SIGHUP by touching its PID file. Finit can do this by itself, however, but having native support for this in sysklgod is highly useful. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
9c2d0cb9fc
commit
a09150a061
10
pidfile.c
10
pidfile.c
@ -118,6 +118,16 @@ int write_pid (char *pidfile)
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* touch_pid
|
||||||
|
*
|
||||||
|
* Touches the specified pidfile f.ex. when receiving a SIGHUP
|
||||||
|
* The result from utimensat() is returned
|
||||||
|
*/
|
||||||
|
int touch_pid (char *pidfile)
|
||||||
|
{
|
||||||
|
return utimensat(0, pidfile, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* remove_pid
|
/* remove_pid
|
||||||
*
|
*
|
||||||
* Remove the the specified file. The result from unlink(2)
|
* Remove the the specified file. The result from unlink(2)
|
||||||
|
@ -42,6 +42,13 @@ int check_pid (char *pidfile);
|
|||||||
*/
|
*/
|
||||||
int write_pid (char *pidfile);
|
int write_pid (char *pidfile);
|
||||||
|
|
||||||
|
/* touch_pid
|
||||||
|
*
|
||||||
|
* Touches the specified pidfile f.ex. when receiving a SIGHUP
|
||||||
|
* The result from utimensat() is returned
|
||||||
|
*/
|
||||||
|
int touch_pid (char *pidfile);
|
||||||
|
|
||||||
/* remove_pid
|
/* remove_pid
|
||||||
*
|
*
|
||||||
* Remove the the specified file. The result from unlink(2)
|
* Remove the the specified file. The result from unlink(2)
|
||||||
|
@ -1161,6 +1161,13 @@ int main(argc, argv)
|
|||||||
restart = 0;
|
restart = 0;
|
||||||
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
|
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
|
||||||
init();
|
init();
|
||||||
|
if (check_pid(PidFile)) {
|
||||||
|
if (touch_pid(PidFile))
|
||||||
|
logerror("Not possible to touch pidfile");
|
||||||
|
} else {
|
||||||
|
if (!write_pid(PidFile))
|
||||||
|
logerror("Failed to write pidfile");
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (nfds == 0) {
|
if (nfds == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user