From a53b32814439f85977617e1d457f5e963fd4da8d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 11 Jul 2016 14:02:16 +0200 Subject: Signal the spawner when the service is initialised enough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gammad.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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)))) -- cgit v1.2.3-70-g09d2