mirror of
https://github.com/swaywm/sway.git
synced 2026-04-16 08:21:30 -04:00
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.
This commit is contained in:
parent
fa497964fd
commit
bd81e3c71f
1 changed files with 9 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue