aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2012-09-12 21:00:20 +0200
committerChristian Ruppert <idl0r@gentoo.org>2012-09-12 21:00:20 +0200
commita06072b3959adc91ddf5157f69162977cbd48079 (patch)
treeccf0c75d21368237871f44b23f553c10400a6c09
parent3863c11be5d48ad4d1a10156f474339bea04f5ae (diff)
Silence get_pid(), OpenRC will give the process some time to create the PID file and the first get__pid() call may fail.
-rw-r--r--src/rc/_usage.h2
-rw-r--r--src/rc/start-stop-daemon.c14
2 files changed, 9 insertions, 7 deletions
diff --git a/src/rc/_usage.h b/src/rc/_usage.h
index 84b66b96..0882c22f 100644
--- a/src/rc/_usage.h
+++ b/src/rc/_usage.h
@@ -38,7 +38,7 @@
"Disable color output", \
"Display software version", \
"Run verbosely", \
- "Run quietly"
+ "Run quietly (Does not affect errors)"
#define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
#define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
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"