mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-27 07:58:07 -04:00
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).
This commit is contained in:
parent
9cb8f6e3b7
commit
8365fde980
1 changed files with 14 additions and 1 deletions
15
url-mode.c
15
url-mode.c
|
|
@ -3,6 +3,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define LOG_MODULE "url-mode"
|
#define LOG_MODULE "url-mode"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
|
|
@ -81,18 +85,27 @@ activate_url(struct seat *seat, struct terminal *term, const struct url *url)
|
||||||
size_t argc;
|
size_t argc;
|
||||||
char **argv;
|
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(
|
if (spawn_expand_template(
|
||||||
&term->conf->url_launch, 1,
|
&term->conf->url_launch, 1,
|
||||||
(const char *[]){"url"},
|
(const char *[]){"url"},
|
||||||
(const char *[]){url_string},
|
(const char *[]){url_string},
|
||||||
&argc, &argv))
|
&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++)
|
for (size_t i = 0; i < argc; i++)
|
||||||
free(argv[i]);
|
free(argv[i]);
|
||||||
free(argv);
|
free(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(dev_null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue