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:
Joachim Nilsson 2018-08-02 15:37:02 +02:00
parent 9c2d0cb9fc
commit a09150a061
3 changed files with 24 additions and 0 deletions

View File

@ -118,6 +118,16 @@ int write_pid (char *pidfile)
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 the the specified file. The result from unlink(2)

View File

@ -42,6 +42,13 @@ int check_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 the the specified file. The result from unlink(2)

View File

@ -1161,6 +1161,13 @@ int main(argc, argv)
restart = 0;
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
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;
}
if (nfds == 0) {