diff -up netkit-rusers-0.17/rpc.rstatd/rstatd.c.sdnotify netkit-rusers-0.17/rpc.rstatd/rstatd.c
--- netkit-rusers-0.17/rpc.rstatd/rstatd.c.sdnotify 2012-09-24 15:57:11.080034637 +0200
+++ netkit-rusers-0.17/rpc.rstatd/rstatd.c 2012-09-24 15:57:11.131034735 +0200
@@ -42,6 +42,7 @@ static char rcsid[] = "$Id: rstatd.c,v 1
#include <rpcsvc/rstat.h>
#include <sys/socket.h>
#include <unistd.h>
+#include <systemd/sd-daemon.h>
extern void rstat_service();
@@ -113,6 +114,26 @@ main(int argc, char *argv[])
exit(1);
}
+ /* If we use systemd as an init system, we may want to give it
+ a message, that this daemon is ready to accept connections.
+ At this time, sockets for receiving connections are already
+ created, so we can say we're ready now. It is a nop if we
+ don't use systemd. */
+ {
+ int result;
+
+ result = sd_notifyf(0, "READY=1\n"
+ "STATUS=Processing requests...\n"
+ "MAINPID=%lu", (unsigned long) getpid());
+
+ /* Return code from sd_notifyf can be ignored, as per sd_notifyf(3).
+ However, if we use systemd's native unit file, we need to send
+ this message to let systemd know that daemon is ready.
+ Thus, we want to know that the call had some issues. */
+ if (result < 0)
+ syslog(LOG_ERR, "sd_notifyf failed: %s\n", strerror(-result));
+ }
+
svc_run();
syslog(LOG_ERR, "svc_run returned");
exit(1);
diff -up netkit-rusers-0.17/rpc.rusersd/rusersd.c.sdnotify netkit-rusers-0.17/rpc.rusersd/rusersd.c
--- netkit-rusers-0.17/rpc.rusersd/rusersd.c.sdnotify 2012-09-24 15:57:11.123034720 +0200
+++ netkit-rusers-0.17/rpc.rusersd/rusersd.c 2012-09-24 15:57:11.133034738 +0200
@@ -38,6 +38,7 @@ char rusersd_rcsid[] =
#include <rpc/pmap_clnt.h>
#include <unistd.h>
#include <grp.h>
+#include <systemd/sd-daemon.h>
#ifdef __GLIBC__
#include <rpcsvc/rusers.h>
#else
@@ -128,6 +129,25 @@ main(void)
}
}
+ /* If we use systemd as an init system, we may want to give it
+ a message, that this daemon is ready to accept connections.
+ At this time, sockets for receiving connections are already
+ created, so we can say we're ready now. It is a nop if we
+ don't use systemd. */
+ {
+ int result;
+
+ result = sd_notifyf(0, "READY=1\n"
+ "STATUS=Processing requests...\n"
+ "MAINPID=%lu", (unsigned long) getpid());
+
+ /* Return code from sd_notifyf can be ignored, as per sd_notifyf(3).
+ However, if we use systemd's native unit file, we need to send
+ this message to let systemd know that daemon is ready.
+ Thus, we want to know that the call had some issues. */
+ if (result < 0)
+ syslog(LOG_ERR, "sd_notifyf failed: %s\n", strerror(-result));
+ }
svc_run();
syslog(LOG_ERR, "svc_run returned");