summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-10-20 21:57:59 +0000
committerLennart Poettering <lennart@poettering.net>2003-10-20 21:57:59 +0000
commit1da17f616cbaed97a41f571397ae17c3ef4ff8e0 (patch)
tree4d5176f78e4f38ad143fcf1c9ce2719dd18ac602 /src
parenta84b6b03c26321d724400525aa3705bdd2f86898 (diff)
0.19 finished
git-svn-id: file:///home/lennart/svn/public/ifplugd/trunk@58 2bf48fe7-cfc1-0310-909f-d9042e1e0fef
Diffstat (limited to 'src')
-rw-r--r--src/ifplugd.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/ifplugd.c b/src/ifplugd.c
index 322870f..5ddf92e 100644
--- a/src/ifplugd.c
+++ b/src/ifplugd.c
@@ -77,6 +77,9 @@ int daemonize = 1,
use_beep = 1,
no_shutdown_script = 0,
wait_on_fork = 0,
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ wait_on_kill = 0,
+#endif
use_syslog = 1,
ignore_retval = 0,
initial_down = 0,
@@ -634,6 +637,9 @@ void usage(char *p) {
" -q --no-shutdown Don't run script on daemon quit (%s)\n"
" -l --initial-down Run \"down\" script on startup if now cable is detected (%s)\n"
" -w --wait-on-fork Wait until daemon fork finished (%s)\n"
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ " -W --wait-on-kill When run with -k, wait until the daemon died (%s)\n"
+#endif
" -x --extra-arg Specify an extra argument for action script\n"
" -M --monitor Use interface monitoring (%s)\n"
" -h --help Show this help\n"
@@ -660,6 +666,9 @@ void usage(char *p) {
no_shutdown_script ? "on" : "off",
initial_down ? "on" : "off",
wait_on_fork ? "on" : "off",
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ wait_on_kill ? "on" : "off",
+#endif
use_ifmonitor ? "on" : "off");
}
@@ -679,6 +688,9 @@ void parse_args(int argc, char *argv[]) {
{"delay-down", required_argument, 0, 'd'},
{"api-mode", required_argument, 0, 'm'},
{"wait-on-fork", no_argument, 0, 'w'},
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ {"wait-on-kill", no_argument, 0, 'W'},
+#endif
{"no-shutdown", no_argument, 0, 'q'},
{"help", no_argument, 0, 'h'},
{"kill", no_argument, 0, 'k'},
@@ -698,7 +710,7 @@ void parse_args(int argc, char *argv[]) {
for (;;) {
int c;
- if ((c = getopt_long(argc, argv, "asni:r:t:u:d:hkbfFvm:qwx:cISRzlM", long_options, &option_index)) < 0)
+ if ((c = getopt_long(argc, argv, "asni:r:t:u:d:hkbfFvm:qwx:cISRzlMW", long_options, &option_index)) < 0)
break;
switch (c) {
@@ -774,7 +786,12 @@ void parse_args(int argc, char *argv[]) {
case 'w':
wait_on_fork = !wait_on_fork;
break;
- case 'x':
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ case 'W':
+ wait_on_kill = !wait_on_kill;
+ break;
+#endif
+ case 'x':
extra_arg = strdup(optarg);
break;
case 'S':
@@ -809,7 +826,16 @@ void parse_args(int argc, char *argv[]) {
}
if (_kill || _resume || _suspend || _info) {
- if (daemon_pid_file_kill(_kill ? SIGINT : (_resume ? SIGUSR2 : (_info ? SIGHUP : SIGUSR1))) < 0) {
+ int rv;
+
+#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE
+ if (_kill && wait_on_kill)
+ rv = daemon_pid_file_kill_wait(SIGINT, 5);
+ else
+#endif
+ rv = daemon_pid_file_kill(_kill ? SIGINT : (_resume ? SIGUSR2 : (_info ? SIGHUP : SIGUSR1)));
+
+ if (rv < 0) {
daemon_log(LOG_ERR, "Failed to kill daemon. (%s)", strerror(errno));
exit(6);
}
@@ -892,7 +918,9 @@ int main(int argc, char* argv[]) {
kill(pid, SIGTERM);
}
-
+ if (c)
+ daemon_log(LOG_ERR, "Daemon failed with error condition #%i. See syslog for details", c);
+
return c;
}
}