manager: ignore return value of unit_watch_pid()

Also, explicitly ignore return value of service_set_main_pid() calls in
few places.

Fixes: CID#1474975
This commit is contained in:
Shreenidhi Shedi 2022-06-04 16:03:30 +05:30
parent 8d862fd39d
commit 5c95eb2888

View file

@ -2235,7 +2235,7 @@ static void service_enter_start(Service *s) {
/* For simple services we immediately start
* the START_POST binaries. */
service_set_main_pid(s, pid);
(void) service_set_main_pid(s, pid);
service_enter_start_post(s);
} else if (s->type == SERVICE_FORKING) {
@ -2253,7 +2253,7 @@ static void service_enter_start(Service *s) {
/* For D-Bus services we know the main pid right away, but wait for the bus name to appear on the
* bus. 'notify' and 'exec' services are similar. */
service_set_main_pid(s, pid);
(void) service_set_main_pid(s, pid);
service_set_state(s, SERVICE_START);
} else
assert_not_reached();
@ -2496,7 +2496,7 @@ static void service_run_next_main(Service *s) {
if (r < 0)
goto fail;
service_set_main_pid(s, pid);
(void) service_set_main_pid(s, pid);
return;
@ -4123,7 +4123,7 @@ static void service_notify_message(
log_unit_debug(u, "New main PID "PID_FMT" does not belong to service, refusing.", new_main_pid);
}
if (r > 0) {
service_set_main_pid(s, new_main_pid);
(void) service_set_main_pid(s, new_main_pid);
r = unit_watch_pid(UNIT(s), new_main_pid, false);
if (r < 0)
@ -4339,8 +4339,8 @@ static int bus_name_pid_lookup_callback(sd_bus_message *reply, void *userdata, s
log_unit_debug(u, "D-Bus name %s is now owned by process " PID_FMT, s->bus_name, (pid_t) pid);
service_set_main_pid(s, pid);
unit_watch_pid(UNIT(s), pid, false);
(void) service_set_main_pid(s, pid);
(void) unit_watch_pid(UNIT(s), pid, false);
return 1;
}