summaryrefslogtreecommitdiff
path: root/src/service.h
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2011-12-03 02:13:30 +0100
committerMichal Schmidt <mschmidt@redhat.com>2011-12-03 21:50:27 +0100
commit3a11183858af30bc9b4e9dac430dd7541deec19b (patch)
treee691cc4eb945d292ac889dcb4c820af9538415d0 /src/service.h
parente92238567b9fc83ef77e359588d7b005ecae3d70 (diff)
service: handle services with racy daemonization gracefully
There are a lot of forking daemons that do not exactly follow the initialization steps as described in daemon(7). It is common that they do not bother waiting in the parent process for the child to write the PID file before exiting. The daemons' developers often do not perceive this as a bug and they're unwilling to change. Currently systemd warns about the missing PID file and falls back to guessing the main PID. Being not quite deterministic, the guess can be wrong with bad consequences. If the guessing is disabled, determinism is achieved at the cost of losing the ability of noticing when the main process of the service dies. As long as it does not negatively affect properly written services, systemd should strive for compatibility even with services with racy daemonization. It is possible to provide determinism _and_ main process supervision to them. If the PID file is not there, rather than guessing and considering the service running immediately after getting the SIGCHLD from the ExecStart (or ExecStartPost) process, we can keep the service in the activating state for a bit longer. We can use inotify to wait for the PID file to appear. Only when it finally does appear and we read a valid PID from it, we'll move the service to the running state. If the PID file never appears, the usual timeout kicks in and the service fails.
Diffstat (limited to 'src/service.h')
-rw-r--r--src/service.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/service.h b/src/service.h
index e28f74b898..15d58cc8ca 100644
--- a/src/service.h
+++ b/src/service.h
@@ -86,6 +86,8 @@ typedef enum NotifyAccess {
_NOTIFY_ACCESS_INVALID = -1
} NotifyAccess;
+typedef struct PathSpec PathSpec;
+
struct Service {
Meta meta;
@@ -157,6 +159,7 @@ struct Service {
Set *configured_sockets;
Watch timer_watch;
+ PathSpec *pid_file_pathspec;
NotifyAccess notify_access;
};