diff --git a/pidfile.c b/pidfile.c index e0959a0..cf53b49 100644 --- a/pidfile.c +++ b/pidfile.c @@ -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) diff --git a/pidfile.h b/pidfile.h index 19d19c1..8f1e490 100644 --- a/pidfile.h +++ b/pidfile.h @@ -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) diff --git a/syslogd.c b/syslogd.c index a176371..8553f15 100644 --- a/syslogd.c +++ b/syslogd.c @@ -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) {