restore '-d' (daemonise) flag
This commit is contained in:
@@ -24,6 +24,7 @@ typedef struct {
|
||||
char *output_name;
|
||||
audio_output *output;
|
||||
int buffer_start_fill;
|
||||
int daemonise;
|
||||
} shairport_cfg;
|
||||
|
||||
extern int debuglev;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user