From a06072b3959adc91ddf5157f69162977cbd48079 Mon Sep 17 00:00:00 2001 From: Christian Ruppert Date: Wed, 12 Sep 2012 21:00:20 +0200 Subject: Silence get_pid(), OpenRC will give the process some time to create the PID file and the first get__pid() call may fail. --- src/rc/start-stop-daemon.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/rc/start-stop-daemon.c') diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index a3d887ac..7c24eadd 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -305,7 +305,7 @@ parse_schedule(const char *string, int timeout) } static pid_t -get_pid(const char *pidfile) +get_pid(const char *pidfile, bool quiet) { FILE *fp; pid_t pid; @@ -314,12 +314,14 @@ get_pid(const char *pidfile) return -1; if ((fp = fopen(pidfile, "r")) == NULL) { - eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno)); + if(!quiet) + eerror("%s: fopen `%s': %s", applet, pidfile, strerror(errno)); return -1; } if (fscanf(fp, "%d", &pid) != 1) { - eerror("%s: no pid found in `%s'", applet, pidfile); + if(!quiet) + eerror("%s: no pid found in `%s'", applet, pidfile); fclose(fp); return -1; } @@ -413,7 +415,7 @@ run_stop_schedule(const char *exec, const char *const *argv, } if (pidfile) { - pid = get_pid(pidfile); + pid = get_pid(pidfile, false); if (pid == -1) return 0; } @@ -1079,7 +1081,7 @@ start_stop_daemon(int argc, char **argv) } if (pidfile) - pid = get_pid(pidfile); + pid = get_pid(pidfile, false); else pid = 0; @@ -1352,7 +1354,7 @@ start_stop_daemon(int argc, char **argv) alive = true; } else { if (pidfile) { - pid = get_pid(pidfile); + pid = get_pid(pidfile, true); if (pid == -1) { eerrorx("%s: did not " "create a valid" -- cgit v1.2.3