In daemon mode, send error messages to parent to write them on stderr.

This allows to get a better error message than "Spawning the daemon failed."
when initialization fails.

The error message is sent through the pipe. When init is OK, just send
a null byte.
This commit is contained in:
Paul Lietar
2013-06-21 11:54:13 +10:00
committed by James Laird
parent 2ffcaa075d
commit aef689c07c
3 changed files with 35 additions and 7 deletions
+7
View File
@@ -34,6 +34,7 @@
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include "common.h"
#include "daemon.h"
shairport_cfg config;
@@ -41,10 +42,16 @@ int debuglev = 0;
void die(char *format, ...) {
fprintf(stderr, "FATAL: ");
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
if (config.daemonise)
daemon_fail(format, args); // Send error message to parent
va_end(args);
fprintf(stderr, "\n");
shairport_shutdown();
}