summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Nurpmeso <steffen@sdaoden.eu>2018-08-11 23:23:15 +0200
committerJuergen Daubert <jue@jue.li>2019-03-23 07:16:12 +0100
commitc0b6ab92c92f6d3ca7eb8a2164b86b29cafa3830 (patch)
tree392b23624820ad5c4a64ff8df8f116306c134922
parent28b8bdb288c056d839390faef1fe7ed07b1061c1 (diff)
downloadstart-stop-daemon-c0b6ab92c92f6d3ca7eb8a2164b86b29cafa3830.tar.gz
start-stop-daemon-c0b6ab92c92f6d3ca7eb8a2164b86b29cafa3830.tar.xz
Sync with Debian Salsa [31ba2b1b10cfcc2149bb43fe9b918355177e4341], 2018-08-01
-rw-r--r--start-stop-daemon.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/start-stop-daemon.c b/start-stop-daemon.c
index 8135750..e972042 100644
--- a/start-stop-daemon.c
+++ b/start-stop-daemon.c
@@ -80,7 +80,6 @@
#include <sys/select.h>
#include <sys/ioctl.h>
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <time.h>
@@ -192,7 +191,7 @@ enum {
};
/* The minimum polling interval, 20ms. */
-static const long MIN_POLL_INTERVAL = 20 * NANOSEC_IN_MILLISEC;
+static const long MIN_POLL_INTERVAL = 20L * NANOSEC_IN_MILLISEC;
static enum action_code action;
static bool testmode = false;
@@ -302,6 +301,25 @@ fatal(const char *format, ...)
exit(2);
}
+#define BUG(...) bug(__FILE__, __LINE__, __func__, __VA_ARGS__)
+
+static void DPKG_ATTR_NORET DPKG_ATTR_PRINTF(4)
+bug(const char *file, int line, const char *func, const char *format, ...)
+{
+ va_list arglist;
+
+ fprintf(stderr, "%s:%s:%d:%s: internal error: ",
+ progname, file, line, func);
+ va_start(arglist, format);
+ vfprintf(stderr, format, arglist);
+ va_end(arglist);
+
+ if (action == ACTION_STATUS)
+ exit(STATUS_UNKNOWN);
+ else
+ exit(3);
+}
+
static void *
xmalloc(int size)
{
@@ -940,7 +958,9 @@ parse_schedule(const char *schedule_str)
schedule[count].value = repeatat;
count++;
}
- assert(count == schedule_length);
+ if (count != schedule_length)
+ BUG("count=%d != schedule_length=%d",
+ count, schedule_length);
}
}
@@ -1289,10 +1309,16 @@ proc_get_psinfo(pid_t pid, struct psinfo *psinfo)
fp = fopen(filename, "r");
if (!fp)
return false;
- if (fread(psinfo, sizeof(*psinfo), 1, fp) == 0)
+ if (fread(psinfo, sizeof(*psinfo), 1, fp) == 0) {
+ fclose(fp);
return false;
- if (ferror(fp))
+ }
+ if (ferror(fp)) {
+ fclose(fp);
return false;
+ }
+
+ fclose(fp);
return true;
}
@@ -2463,7 +2489,7 @@ run_stop_schedule(void)
else if (userspec)
set_what_stop("process(es) owned by '%s'", userspec);
else
- fatal("internal error, no match option, please report");
+ BUG("no match option, please report");
anykilled = false;
retry_nr = 0;
@@ -2501,7 +2527,8 @@ run_stop_schedule(void)
else
continue;
default:
- assert(!"schedule[].type value must be valid");
+ BUG("schedule[%d].type value %d is not valid",
+ position, schedule[position].type);
}
}

Generated by cgit