restore '-d' (daemonise) flag

This commit is contained in:
James Laird
2013-04-14 20:17:40 +10:00
parent a9c40871de
commit 9894b52b7b
3 changed files with 15 additions and 1 deletions
+1
View File
@@ -24,6 +24,7 @@ typedef struct {
char *output_name;
audio_output *output;
int buffer_start_fill;
int daemonise;
} shairport_cfg;
extern int debuglev;
+8
View File
@@ -758,6 +758,14 @@ void rtsp_listen_loop(void) {
mdns_register();
if (config.daemonise) {
pid_t pid = fork();
if (pid) {
printf("%d\n", pid);
exit(0);
}
}
printf("Listening for connections.\n");
int acceptfd;
+6 -1
View File
@@ -59,6 +59,8 @@ void usage(char *progname) {
" -o output set audio output\n"
" -b fill set how full the buffer must be before audio output starts\n"
" This value is in frames; default %d\n"
" -d fork (daemonise)\n"
" The PID of the child process is written to stdout\n"
"Run %s -o <output> -h to find the available options for a specific output\n"
"\n", config.buffer_start_fill, progname);
@@ -74,13 +76,16 @@ void usage(char *progname) {
int parse_options(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "+hvp:a:o:b:")) > 0) {
while ((opt = getopt(argc, argv, "+hdvp:a:o:b:")) > 0) {
switch (opt) {
default:
printf("Unknown argument -%c\n", optopt);
case 'h':
usage(argv[0]);
exit(1);
case 'd':
config.daemonise = 1;
break;
case 'v':
debuglev++;
break;