aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-24 20:30:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-24 20:30:58 +0000
commit8365fde980ccb7f28627805a75f4884df14d7004 (patch)
tree311c96aad0109aaf9c3d0569cabe68361c0f5995
parentspawn: handle custom stdin/stdout/stderr fds being the same (diff)
url-mode: redirect stdin/stdout/stderr to /dev/null when opening an URL
This fixex an issue where TUI programs started in the parent terminal (when running nested terminals).
-rw-r--r--url-mode.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/url-mode.c b/url-mode.c
index bc6e7722..cea099e9 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -3,6 +3,10 @@
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
+#include <unistd.h>
+
+#include <sys/stat.h>
+#include <fcntl.h>
#define LOG_MODULE "url-mode"
#define LOG_ENABLE_DBG 0
@@ -81,18 +85,27 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url)
size_t argc;
char **argv;
+ int dev_null = open("/dev/null", O_RDWR);
+
+ if (dev_null < 0) {
+ LOG_ERRNO("failed to open /dev/null");
+ break;
+ }
+
if (spawn_expand_template(
&term->conf->url_launch, 1,
(const char *[]){"url"},
(const char *[]){url_string},
&argc, &argv))
{
- spawn(term->reaper, term->cwd, argv, -1, -1, -1);
+ spawn(term->reaper, term->cwd, argv, dev_null, dev_null, dev_null);
for (size_t i = 0; i < argc; i++)
free(argv[i]);
free(argv);
}
+
+ close(dev_null);
break;
}
}