chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
list: make our list macros a bit easier to use by not requring type spec on each...
[elogind.git]
/
src
/
core
/
service.c
diff --git
a/src/core/service.c
b/src/core/service.c
index 246a86e23f3cda577a46ee5d286e5051278c1695..96ed2d303a9073d268fd997fa8f836f8dec59cc7 100644
(file)
--- a/
src/core/service.c
+++ b/
src/core/service.c
@@
-191,7
+191,13
@@
static int service_set_main_pid(Service *s, pid_t pid) {
if (pid == getpid())
return -EINVAL;
if (pid == getpid())
return -EINVAL;
- service_unwatch_main_pid(s);
+ if (s->main_pid == pid && s->main_pid_known)
+ return 0;
+
+ if (s->main_pid != pid) {
+ service_unwatch_main_pid(s);
+ exec_status_start(&s->main_exec_status, pid);
+ }
s->main_pid = pid;
s->main_pid_known = true;
s->main_pid = pid;
s->main_pid_known = true;
@@
-205,8
+211,6
@@
static int service_set_main_pid(Service *s, pid_t pid) {
} else
s->main_pid_alien = false;
} else
s->main_pid_alien = false;
- exec_status_start(&s->main_exec_status, pid);
-
return 0;
}
return 0;
}
@@
-1765,11
+1769,9
@@
static int service_spawn(
} else
unit_unwatch_timer(UNIT(s), &s->timer_watch);
} else
unit_unwatch_timer(UNIT(s), &s->timer_watch);
- argv = unit_full_printf_strv(UNIT(s), c->argv);
- if (!argv) {
- r = -ENOMEM;
+ r = unit_full_printf_strv(UNIT(s), c->argv, &argv);
+ if (r < 0)
goto fail;
goto fail;
- }
our_env = new0(char*, 5);
if (!our_env) {
our_env = new0(char*, 5);
if (!our_env) {
@@
-1822,7
+1824,7
@@
static int service_spawn(
apply_chroot,
apply_tty_stdin,
UNIT(s)->manager->confirm_spawn,
apply_chroot,
apply_tty_stdin,
UNIT(s)->manager->confirm_spawn,
- UNIT(s)->
cgroup_mask
,
+ UNIT(s)->
manager->cgroup_supported
,
path,
UNIT(s)->id,
s->type == SERVICE_IDLE ? UNIT(s)->manager->idle_pipe : NULL,
path,
UNIT(s)->id,
s->type == SERVICE_IDLE ? UNIT(s)->manager->idle_pipe : NULL,
@@
-2649,6
+2651,9
@@
static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
if (s->exec_context.var_tmp_dir)
unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir);
if (s->exec_context.var_tmp_dir)
unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir);
+ if (s->forbid_restart)
+ unit_serialize_item(u, f, "forbid-restart", yes_no(s->forbid_restart));
+
return 0;
}
return 0;
}
@@
-2698,8
+2703,10
@@
static int service_deserialize_item(Unit *u, const char *key, const char *value,
if (parse_pid(value, &pid) < 0)
log_debug_unit(u->id, "Failed to parse main-pid value %s", value);
if (parse_pid(value, &pid) < 0)
log_debug_unit(u->id, "Failed to parse main-pid value %s", value);
- else
- service_set_main_pid(s, (pid_t) pid);
+ else {
+ service_set_main_pid(s, pid);
+ unit_watch_pid(UNIT(s), pid);
+ }
} else if (streq(key, "main-pid-known")) {
int b;
} else if (streq(key, "main-pid-known")) {
int b;
@@
-2783,6
+2790,14
@@
static int service_deserialize_item(Unit *u, const char *key, const char *value,
return log_oom();
s->exec_context.var_tmp_dir = t;
return log_oom();
s->exec_context.var_tmp_dir = t;
+ } else if (streq(key, "forbid-restart")) {
+ int b;
+
+ b = parse_boolean(value);
+ if (b < 0)
+ log_debug_unit(u->id, "Failed to parse forbid-restart value %s", value);
+ else
+ s->forbid_restart = b;
} else
log_debug_unit(u->id, "Unknown serialization key '%s'", key);
} else
log_debug_unit(u->id, "Unknown serialization key '%s'", key);
@@
-3391,6
+3406,7
@@
static void service_notify_message(Unit *u, pid_t pid, char **tags) {
log_debug_unit(u->id,
"%s: got %s", u->id, e);
service_set_main_pid(s, pid);
log_debug_unit(u->id,
"%s: got %s", u->id, e);
service_set_main_pid(s, pid);
+ unit_watch_pid(UNIT(s), pid);
}
}
}
}
@@
-3687,8
+3703,10
@@
static void service_bus_query_pid_done(
(s->state == SERVICE_START ||
s->state == SERVICE_START_POST ||
s->state == SERVICE_RUNNING ||
(s->state == SERVICE_START ||
s->state == SERVICE_START_POST ||
s->state == SERVICE_RUNNING ||
- s->state == SERVICE_RELOAD))
+ s->state == SERVICE_RELOAD))
{
service_set_main_pid(s, pid);
service_set_main_pid(s, pid);
+ unit_watch_pid(UNIT(s), pid);
+ }
}
int service_set_socket_fd(Service *s, int fd, Socket *sock) {
}
int service_set_socket_fd(Service *s, int fd, Socket *sock) {