summaryrefslogtreecommitdiffstats
path: root/spawn.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2023-04-03 08:50:49 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2023-04-03 08:54:06 +0100
commitb9524f5b72d16bd634fc47ad1a4a9d3240bd4370 (patch)
tree3ba1c13ceb700287d649b6caeb20fc2fe63be977 /spawn.c
parent22eb0334c325245e7a49610f91c7842cb6408f4d (diff)
Add support for spawning panes in separate cgroups with systemd and a configure
flag to disable. From Eric T Johnson yut23 AT gvljohnsons DOT com in GitHub issue 3514.
Diffstat (limited to 'spawn.c')
-rw-r--r--spawn.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/spawn.c b/spawn.c
index e63133fe..10604028 100644
--- a/spawn.c
+++ b/spawn.c
@@ -380,8 +380,20 @@ spawn_pane(struct spawn_context *sc, char **cause)
}
/* In the parent process, everything is done now. */
- if (new_wp->pid != 0)
+ if (new_wp->pid != 0) {
+#if defined(HAVE_SYSTEMD) && defined(ENABLE_CGROUPS)
+ /*
+ * Move the child process into a new cgroup for systemd-oomd
+ * isolation.
+ */
+ if (systemd_move_pid_to_new_cgroup(new_wp->pid, cause) < 0) {
+ log_debug("%s: moving pane to new cgroup failed: %s",
+ __func__, *cause);
+ free (*cause);
+ }
+#endif
goto complete;
+ }
/*
* Child process. Change to the working directory or home if that