diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-11 14:02:16 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-11 14:02:16 +0200 |
commit | a53b32814439f85977617e1d457f5e963fd4da8d (patch) | |
tree | 4bf04f88fe1ab375c06563becf02568551777705 /src | |
parent | Use exit value 2 to indicate that the service is already running (diff) | |
download | coopgammad-a53b32814439f85977617e1d457f5e963fd4da8d.tar.gz coopgammad-a53b32814439f85977617e1d457f5e963fd4da8d.tar.bz2 coopgammad-a53b32814439f85977617e1d457f5e963fd4da8d.tar.xz |
Signal the spawner when the service is initialised enough
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | src/gammad.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gammad.c b/src/gammad.c index ad4d255..eef65b7 100644 --- a/src/gammad.c +++ b/src/gammad.c @@ -373,6 +373,10 @@ static void usage(void) /** + * Must not be started without stdout or stderr (may be /dev/null) + * + * The process closes stdout when the socket has been created + * * @return 0: Successful * 1: An error occurred * 2: Already running @@ -432,6 +436,15 @@ int main(int argc, char** argv) goto fail; } + /* TODO socket */ + + /* Signal the spawner that the service is ready */ + close(STDOUT_FILENO); + /* Avoid potential catastrophes that would occur if a library that is being + * used was so mindless as to write to stdout. */ + if (dup2(STDERR_FILENO, STDOUT_FILENO) < 0) + perror(argv0); + /* Get partitions */ if (site.partitions_available) if (!(partitions = calloc(site.partitions_available, sizeof(*partitions)))) |