mirror of
https://github.com/tmux/tmux.git
synced 2026-03-26 13:16:37 +00:00
Work around systemd killing panes early during system shutdown by creating
dependencies from the panes to the service which started tmux, GitHub issue 4926 from Dmitry Torokhov.
This commit is contained in:
@@ -81,7 +81,8 @@ struct systemd_job_watch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
job_removed_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
|
job_removed_handler(sd_bus_message *m, void *userdata,
|
||||||
|
__unused sd_bus_error *ret_error)
|
||||||
{
|
{
|
||||||
struct systemd_job_watch *watch = userdata;
|
struct systemd_job_watch *watch = userdata;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
@@ -109,7 +110,7 @@ systemd_move_to_new_cgroup(char **cause)
|
|||||||
sd_bus_message *m = NULL, *reply = NULL;
|
sd_bus_message *m = NULL, *reply = NULL;
|
||||||
sd_bus *bus = NULL;
|
sd_bus *bus = NULL;
|
||||||
sd_bus_slot *slot = NULL;
|
sd_bus_slot *slot = NULL;
|
||||||
char *name, *desc, *slice;
|
char *name, *desc, *slice, *unit;
|
||||||
sd_id128_t uuid;
|
sd_id128_t uuid;
|
||||||
int r;
|
int r;
|
||||||
uint64_t elapsed_usec;
|
uint64_t elapsed_usec;
|
||||||
@@ -241,6 +242,26 @@ systemd_move_to_new_cgroup(char **cause)
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try locating systemd unit that started the server, and mark pane units
|
||||||
|
* as dependent on it. Use "Before" to make sure systemd will not try to
|
||||||
|
* kill them first.
|
||||||
|
*/
|
||||||
|
if (sd_pid_get_user_unit(parent_pid, &unit) == 0 ||
|
||||||
|
sd_pid_get_unit(parent_pid, &unit) == 0) {
|
||||||
|
r = sd_bus_message_append(m, "(sv)", "Before", "as", 1, unit);
|
||||||
|
if (r >= 0) {
|
||||||
|
r = sd_bus_message_append(m, "(sv)", "PartOf", "as", 1,
|
||||||
|
unit);
|
||||||
|
}
|
||||||
|
free(unit);
|
||||||
|
if (r < 0) {
|
||||||
|
xasprintf(cause, "failed to append to properties: %s",
|
||||||
|
strerror(-r));
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* End properties array. */
|
/* End properties array. */
|
||||||
r = sd_bus_message_close_container(m);
|
r = sd_bus_message_close_container(m);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user