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.
---
command.c | 6 ++++++
ui.c | 6 ++++++
url.c | 12 ++++++++++++
3 files changed, 24 insertions(+)
diff --git a/command.c b/command.c
index 4c290fc..0ff7ce5 100644
--- a/command.c
+++ b/command.c
@@ -472,6 +472,12 @@ static void commandExec(uint id, char *params) {
if (pid < 0) err(EX_OSERR, "fork");
if (pid) return;
+ pid = setsid();
+ if (pid) {
+ warn("setsid");
+ _exit(EX_UNAVAILABLE);
+ }
+
close(STDIN_FILENO);
dup2(execPipe[1], STDOUT_FILENO);
dup2(utilPipe[1], STDERR_FILENO);
diff --git a/ui.c b/ui.c
index 1b21cc5..5284c2a 100644
--- a/ui.c
+++ b/ui.c
@@ -567,6 +567,12 @@ static void notify(uint id, const char *str) {
if (pid < 0) err(EX_OSERR, "fork");
if (pid) return;
+ pid = setsid();
+ if (pid) {
+ warn("setsid");
+ _exit(EX_UNAVAILABLE);
+ }
+
close(STDIN_FILENO);
dup2(utilPipe[1], STDOUT_FILENO);
dup2(utilPipe[1], STDERR_FILENO);
diff --git a/url.c b/url.c
index 9de2f9a..526dc42 100644
--- a/url.c
+++ b/url.c
@@ -123,6 +123,12 @@ static void urlOpen(const char *url) {
if (pid < 0) err(EX_OSERR, "fork");
if (pid) return;
+ pid = setsid();
+ if (pid) {
+ warn("setsid");
+ _exit(EX_UNAVAILABLE);
+ }
+
close(STDIN_FILENO);
dup2(utilPipe[1], STDOUT_FILENO);
dup2(utilPipe[1], STDERR_FILENO);
@@ -174,6 +180,12 @@ static void urlCopy(const char *url) {
return;
}
+ pid = setsid();
+ if (pid) {
+ warn("setsid");
+ _exit(EX_UNAVAILABLE);
+ }
+
dup2(rw[0], STDIN_FILENO);
dup2(utilPipe[1], STDOUT_FILENO);
dup2(utilPipe[1], STDERR_FILENO);
--
2.32.0