From bd81e3c71f24de100d67368747c0ed8bb604a8ba Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Sun, 8 Feb 2026 01:17:47 +0900 Subject: [PATCH] commands/exec: redirect child stdio to /dev/null Children spawned via exec inherit sway's stdio pointing to the launch TTY. wlroots puts the TTY in KD_GRAPHICS mode, where writes block, causing programs that write to stdout/stderr on startup (e.g. Electron apps) to hang. --- sway/commands/exec_always.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index a966696c5..8a0d2bdd6 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -53,6 +54,14 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { if (child == 0) { setsid(); + int devnull = open("/dev/null", O_RDWR); + if (devnull > STDERR_FILENO) { + dup2(devnull, STDIN_FILENO); + dup2(devnull, STDOUT_FILENO); + dup2(devnull, STDERR_FILENO); + close(devnull); + } + if (ctx) { const char *token = launcher_ctx_get_token_name(ctx); setenv("XDG_ACTIVATION_TOKEN", token, 1);