X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=blobdiff_plain;f=src%2Fmain-afb-daemon.c;h=65481c4340821993e9da1f542038cfe04127f263;hp=77d7ab299ee4742ce741708b98ca261f5f25a74c;hb=deaf20980bcacd8731e9228c86f528ac480c7f55;hpb=86e4c175b0c35d38c8a214ae1c6afce6ad6aac4c diff --git a/src/main-afb-daemon.c b/src/main-afb-daemon.c index 77d7ab29..65481c43 100644 --- a/src/main-afb-daemon.c +++ b/src/main-afb-daemon.c @@ -215,13 +215,14 @@ static void setup_daemon() +--------------------------------------------------------- */ static void daemonize() { - int fd = 0, daemon; + int fd = 0, daemon, nostdin; const char *output; pid_t pid; daemon = 0; output = NULL; wrap_json_unpack(main_config, "{s?b s?s}", "daemon", &daemon, "output", &output); + nostdin = 0; if (output) { fd = open(output, O_WRONLY | O_APPEND | O_CREAT, 0640); @@ -241,6 +242,8 @@ static void daemonize() } if (pid != 0) _exit(0); + + nostdin = 1; } /* closes the input */ @@ -253,8 +256,8 @@ static void daemonize() close(fd); } - /* after that ctrl+C still works */ - close(0); + if (nostdin) + close(0); /* except if 'daemon', ctrl+C still works after that */ } /*---------------------------------------------------------