sfeed_curses: close stdin for spawning a plumb program in non-interactive mode
This is only for plumbing in non-interactive mode in forkexec(), but not piping content. Probably obvious what the descriptors are, but also add a few comments to dup2 of the file descriptors (stdin, stdout, stderr). To reproduce a behaviour: Plumb script: #!/bin/sh dmenu Then launch it: SFEED_PLUMB_INTERACTIVE=0 SFEED_PLUMB=thescript sfeed_curses ~/.sfeed/feeds/* The program now waits on input while in non-interactive mode and only seems to hang. After: The program starts but just has no input passed to it.
This commit is contained in:
parent
f0ca847fca
commit
78e5435937
|
@ -1,4 +1,4 @@
|
||||||
.Dd May 4, 2022
|
.Dd May 5, 2022
|
||||||
.Dt SFEED_CURSES 1
|
.Dt SFEED_CURSES 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -290,6 +290,7 @@ In non-interactive mode
|
||||||
.Nm
|
.Nm
|
||||||
doesn't wait until the process exits.
|
doesn't wait until the process exits.
|
||||||
Stdout and stderr of the program are not written as output.
|
Stdout and stderr of the program are not written as output.
|
||||||
|
When plumbing an URL then stdin is closed also.
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Ex -std
|
.Ex -std
|
||||||
The exit status is 130 on SIGINT and 143 on SIGTERM.
|
The exit status is 130 on SIGINT and 143 on SIGTERM.
|
||||||
|
|
|
@ -604,8 +604,8 @@ pipeitem(const char *cmd, struct item *item, int field, int interactive)
|
||||||
die("fork");
|
die("fork");
|
||||||
case 0:
|
case 0:
|
||||||
if (!interactive) {
|
if (!interactive) {
|
||||||
dup2(devnullfd, 1);
|
dup2(devnullfd, 1); /* stdout */
|
||||||
dup2(devnullfd, 2);
|
dup2(devnullfd, 2); /* stderr */
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -642,8 +642,9 @@ forkexec(char *argv[], int interactive)
|
||||||
die("fork");
|
die("fork");
|
||||||
case 0:
|
case 0:
|
||||||
if (!interactive) {
|
if (!interactive) {
|
||||||
dup2(devnullfd, 1);
|
dup2(devnullfd, 0); /* stdin */
|
||||||
dup2(devnullfd, 2);
|
dup2(devnullfd, 1); /* stdout */
|
||||||
|
dup2(devnullfd, 2); /* stderr */
|
||||||
}
|
}
|
||||||
if (execvp(argv[0], argv) == -1)
|
if (execvp(argv[0], argv) == -1)
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
@ -1847,8 +1848,8 @@ markread(struct pane *p, off_t from, off_t to, int isread)
|
||||||
case -1:
|
case -1:
|
||||||
die("fork");
|
die("fork");
|
||||||
case 0:
|
case 0:
|
||||||
dup2(devnullfd, 1);
|
dup2(devnullfd, 1); /* stdout */
|
||||||
dup2(devnullfd, 2);
|
dup2(devnullfd, 2); /* stderr */
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (!(fp = popen(cmd, "w")))
|
if (!(fp = popen(cmd, "w")))
|
||||||
|
|
Loading…
Reference in New Issue