aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-07-05 15:44:21 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-07-05 15:44:21 +0200
commit3752a7879bb0d34d845470bc3a9face55662292a (patch)
treecab52f04bb2ca64ff54a6f6e195e3aa4d1ae52a2
parent9dd18c6373cd68a978a4994a9cb7219d4d748471 (diff)
downloadriver-3752a7879bb0d34d845470bc3a9face55662292a.tar.gz
river-3752a7879bb0d34d845470bc3a9face55662292a.tar.xz
server: send SIGTERM to startup process on exit
-rw-r--r--doc/river.1.scd9
-rw-r--r--river/main.zig9
2 files changed, 12 insertions, 6 deletions
diff --git a/doc/river.1.scd b/doc/river.1.scd
index e79e6cb..2219c30 100644
--- a/doc/river.1.scd
+++ b/doc/river.1.scd
@@ -16,9 +16,12 @@ bspwm based on wlroots and written in Zig.
*-c* _shell_command_
Run a shell command or give the path to a script that will be run
- before river gets started. This is where you define keymaps using
- *riverctl*(1) and autostart programs. Make sure the script is
- executable.
+ after river's wayland server is initialized but before entering the
+ main loop. You may use this to configure river and define keymaps
+ using *riverctl*(1), start programs such as a status bar, or perhaps
+ run a service manager. If the process started by this flag is still
+ running when river exits, river will send SIGTERM and and wait for it
+ to terminate.
*-l* _log_level_
Set the log level of river to a value from 0 to 7 with 0 being the
diff --git a/river/main.zig b/river/main.zig
index d7875da..e01b95a 100644
--- a/river/main.zig
+++ b/river/main.zig
@@ -85,12 +85,15 @@ pub fn main() anyerror!void {
try server.start();
- if (startup_command) |cmd| {
+ const startup_process = if (startup_command) |cmd| blk: {
const child_args = [_][]const u8{ "/bin/sh", "-c", cmd };
const child = try std.ChildProcess.init(&child_args, util.gpa);
- defer child.deinit();
try std.ChildProcess.spawn(child);
- }
+ break :blk child;
+ } else null;
+ defer if (startup_process) |child| {
+ _ = child.kill() catch |e| log.err(.server, "failed to terminate startup process: {}", .{e});
+ };
log.info(.server, "running...", .{});