print_desc() - Allow arguments to be NULL.

Signed-off-by: Joachim Nilsson <joachim.nilsson@westermo.se>
This commit is contained in:
Joachim Nilsson committed 2014-04-19 22:25:56 +02:00
1 parent 1bf3aa528a
commit be3257f805
1 file changed
+6 -2
+6 -2
View File
@@ -151,7 +151,7 @@ pid_t pidfile_read(char *pidfile)
errno = 0; errno = 0;
pid = strtoul(buf, NULL, 0); pid = strtoul(buf, NULL, 0);
if (errno) if (errno)
pid = 0; /* Failed conversion. */ pid = 0; /* Failed conversion. */
} }
fclose(fp); fclose(fp);
@@ -338,7 +338,11 @@ void print_desc(char *action, char *desc)
print_timestamp(); print_timestamp();
write(STDERR_FILENO, "\r", 1); write(STDERR_FILENO, "\r", 1);
if (!action)
action = "";
write(STDERR_FILENO, action, strlen(action)); write(STDERR_FILENO, action, strlen(action));
if (!desc)
desc = "";
write(STDERR_FILENO, desc, strlen(desc)); write(STDERR_FILENO, desc, strlen(desc));
write(STDERR_FILENO, dots, 60 - strlen(desc) - strlen(action)); /* pad with dots. */ write(STDERR_FILENO, dots, 60 - strlen(desc) - strlen(action)); /* pad with dots. */
} }
@@ -422,7 +426,7 @@ int run(char *cmd)
struct sigaction sa; struct sigaction sa;
/* Reset signal handlers that were set by the parent process */ /* Reset signal handlers that were set by the parent process */
for (i = 1; i < NSIG; i++) for (i = 1; i < NSIG; i++)
DFLSIG(sa, i, 0); DFLSIG(sa, i, 0);
/* Redirect stdio if the caller requested so. */ /* Redirect stdio if the caller requested so. */