cmd_exec{,_always}: close standard in for child

This just closes the standard input for processes started with the exec
and exec_always commands. This prevents interactive programs like vi(m)
from taking over input on the getty. Standard output and standard error
are kept open, which allows for the output/errors to be captured along
with the sway log.
This commit is contained in:
Brian Ashworth 2019-06-05 15:11:16 -04:00
parent b4b274cdce
commit bc1b118b95

View file

@ -61,6 +61,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
close(fd[0]); close(fd[0]);
if ((child = fork()) == 0) { if ((child = fork()) == 0) {
close(fd[1]); close(fd[1]);
close(STDIN_FILENO);
execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
_exit(0); _exit(0);
} }