server: send SIGTERM to startup process on exit

This commit is contained in:
Isaac Freund 2020-07-05 15:44:21 +02:00
parent 9dd18c6373
commit 3752a7879b
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 12 additions and 6 deletions

View file

@ -16,9 +16,12 @@ bspwm based on wlroots and written in Zig.
*-c* _shell_command_ *-c* _shell_command_
Run a shell command or give the path to a script that will be run 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 after river's wayland server is initialized but before entering the
*riverctl*(1) and autostart programs. Make sure the script is main loop. You may use this to configure river and define keymaps
executable. 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_ *-l* _log_level_
Set the log level of river to a value from 0 to 7 with 0 being the Set the log level of river to a value from 0 to 7 with 0 being the

View file

@ -85,12 +85,15 @@ pub fn main() anyerror!void {
try server.start(); 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_args = [_][]const u8{ "/bin/sh", "-c", cmd };
const child = try std.ChildProcess.init(&child_args, util.gpa); const child = try std.ChildProcess.init(&child_args, util.gpa);
defer child.deinit();
try std.ChildProcess.spawn(child); 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...", .{}); log.info(.server, "running...", .{});