about summary refs log tree commit diff
path: root/url.c
diff options
context:
space:
mode:
authorKlemens Nanni <klemens@posteo.de>2021-06-13 02:28:15 +0000
committerJune McEnroe <june@causal.agency>2021-06-13 16:46:34 -0400
commit9c7ceb23bb9ffaa40af2c7bb50130bb66c607593 (patch)
treec7662e2c0bd05bdbcd79d9f6cd1b02143a008222 /url.c
parentExit on data directory creation error (diff)
downloadcatgirl-9c7ceb23bb9ffaa40af2c7bb50130bb66c607593.tar.gz
catgirl-9c7ceb23bb9ffaa40af2c7bb50130bb66c607593.zip
/exec without controlling terminal
Otherwise "/exec sh </dev/tty" takes over and catgirl must effectively
be killed to stop the madness;  with this diff:

	catgirl  input| /exec sh </dev/tty
	catgirl output| /bin/sh: cannot open /dev/tty: Device not configured
	catgirl output| Process exits with status 1

Do the same for `-C/Copy', `-N/notify' and `-O/open' alike.
Diffstat (limited to 'url.c')
-rw-r--r--url.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/url.c b/url.c
index 9de2f9a..219a83c 100644
--- a/url.c
+++ b/url.c
@@ -123,6 +123,7 @@ static void urlOpen(const char *url) {
 	if (pid < 0) err(EX_OSERR, "fork");
 	if (pid) return;
 
+	setsid();
 	close(STDIN_FILENO);
 	dup2(utilPipe[1], STDOUT_FILENO);
 	dup2(utilPipe[1], STDERR_FILENO);
@@ -174,6 +175,7 @@ static void urlCopy(const char *url) {
 		return;
 	}
 
+	setsid();
 	dup2(rw[0], STDIN_FILENO);
 	dup2(utilPipe[1], STDOUT_FILENO);
 	dup2(utilPipe[1], STDERR_FILENO);