]>
Commit | Line | Data |
---|---|---|
1 | diff --git a/udevcontrol.c b/udevcontrol.c | |
2 | index a983f22..4220eda 100644 | |
3 | --- a/udevcontrol.c | |
4 | +++ b/udevcontrol.c | |
5 | @@ -83,6 +83,8 @@ int main(int argc, char *argv[], char *e | |
6 | ctrl_msg.type = UDEVD_CTRL_START_EXEC_QUEUE; | |
7 | else if (!strcmp(arg, "reload_rules")) | |
8 | ctrl_msg.type = UDEVD_CTRL_RELOAD_RULES; | |
9 | + else if (!strcmp(arg, "restart")) | |
10 | + ctrl_msg.type = UDEVD_CTRL_RESTART; | |
11 | else if (!strncmp(arg, "log_priority=", strlen("log_priority="))) { | |
12 | intval = (int *) ctrl_msg.buf; | |
13 | val = &arg[strlen("log_priority=")]; | |
14 | @@ -123,6 +125,7 @@ int main(int argc, char *argv[], char *e | |
15 | " stop_exec_queue keep udevd from executing events, queue only\n" | |
16 | " start_exec_queue execute events, flush queue\n" | |
17 | " reload_rules reloads the rules files\n" | |
18 | + " restart tells udevd to restart itself\n" | |
19 | " max_childs=<N> maximum number of childs\n" | |
20 | " max_childs_running=<N> maximum number of childs running at the same time\n" | |
21 | " --help print this help text\n\n"); | |
22 | diff --git a/udevd.c b/udevd.c | |
23 | index bb956b5..6e8f6df 100644 | |
24 | --- a/udevd.c | |
25 | +++ b/udevd.c | |
26 | @@ -703,6 +703,13 @@ static void get_ctrl_msg(void) | |
27 | info("udevd message (RELOAD_RULES) received"); | |
28 | reload_config = 1; | |
29 | break; | |
30 | + case UDEVD_CTRL_RESTART: { | |
31 | + char *argv[2] = { "/proc/self/exe", NULL }; | |
32 | + info("udevd message (RESTART) received"); | |
33 | + if (execve(argv[0], argv, environ) == -1) | |
34 | + err("unable to restart udevd: %s", strerror(errno)); | |
35 | + break; | |
36 | + } | |
37 | default: | |
38 | err("unknown control message type"); | |
39 | } | |
40 | @@ -847,6 +854,9 @@ static int init_udevd_socket(void) | |
41 | ||
42 | /* enable receiving of the sender credentials */ | |
43 | setsockopt(udevd_sock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on)); | |
44 | + retval = fcntl(udevd_sock, F_GETFD); | |
45 | + if (retval != -1) | |
46 | + fcntl(udevd_sock, F_SETFD, retval | FD_CLOEXEC); | |
47 | ||
48 | return 0; | |
49 | } | |
50 | diff --git a/udevd.h b/udevd.h | |
51 | index fce86e7..d681da5 100644 | |
52 | --- a/udevd.h | |
53 | +++ b/udevd.h | |
54 | @@ -46,6 +46,7 @@ enum udevd_ctrl_msg_type { | |
55 | UDEVD_CTRL_SET_MAX_CHILDS, | |
56 | UDEVD_CTRL_SET_MAX_CHILDS_RUNNING, | |
57 | UDEVD_CTRL_RELOAD_RULES, | |
58 | + UDEVD_CTRL_RESTART, | |
59 | }; | |
60 | ||
61 | struct udevd_ctrl_msg { |