parent
c4c5113fbd
commit
4dec55eead
4 changed files with 21 additions and 49 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
int extpipeactive = 0;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
#if EXTERNALPIPEIN_PATCH
|
#if EXTERNALPIPEIN_PATCH
|
||||||
extpipe(const Arg *arg, int in)
|
extpipe(const Arg *arg, int in)
|
||||||
|
|
@ -64,7 +62,6 @@ externalpipe(const Arg *arg)
|
||||||
close(to[1]);
|
close(to[1]);
|
||||||
/* restore */
|
/* restore */
|
||||||
signal(SIGPIPE, oldsigpipe);
|
signal(SIGPIPE, oldsigpipe);
|
||||||
extpipeactive = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EXTERNALPIPEIN_PATCH
|
#if EXTERNALPIPEIN_PATCH
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,5 @@ newterm(const Arg* a)
|
||||||
default:
|
default:
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
wait(NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
plumb(char *sel) {
|
plumb(char *sel)
|
||||||
|
{
|
||||||
if (sel == NULL)
|
if (sel == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
pid_t child;
|
pid_t child;
|
||||||
|
|
||||||
if (subprocwd(cwd) != 0)
|
if (subprocwd(cwd) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(child = fork()) {
|
switch (child = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
return;
|
return;
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -18,7 +21,5 @@ plumb(char *sel) {
|
||||||
if (execvp(plumb_cmd, (char *const []){plumb_cmd, sel, 0}) == -1)
|
if (execvp(plumb_cmd, (char *const []){plumb_cmd, sel, 0}) == -1)
|
||||||
exit(1);
|
exit(1);
|
||||||
exit(0);
|
exit(0);
|
||||||
default:
|
|
||||||
waitpid(child, NULL, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
54
st.c
54
st.c
|
|
@ -820,40 +820,19 @@ sigchld(int a)
|
||||||
int stat;
|
int stat;
|
||||||
pid_t p;
|
pid_t p;
|
||||||
|
|
||||||
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
while ((p = waitpid(-1, &stat, WNOHANG)) > 0) {
|
||||||
if ((p = waitpid((extpipeactive ? -1 : pid), &stat, WNOHANG)) < 0)
|
if (p == pid) {
|
||||||
#else
|
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
||||||
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
close(csdfd);
|
||||||
#endif // EXTERNALPIPEIN_PATCH
|
#endif // EXTERNALPIPEIN_PATCH
|
||||||
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
|
||||||
|
|
||||||
#if EXTERNALPIPE_PATCH
|
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
||||||
if (pid != p) {
|
die("child exited with status %d\n", WEXITSTATUS(stat));
|
||||||
if (!extpipeactive)
|
else if (WIFSIGNALED(stat))
|
||||||
return;
|
die("child terminated due to signal %d\n", WTERMSIG(stat));
|
||||||
|
_exit(0);
|
||||||
if (p == 0 && wait(&stat) < 0)
|
}
|
||||||
die("wait: %s\n", strerror(errno));
|
|
||||||
|
|
||||||
/* reinstall sigchld handler */
|
|
||||||
signal(SIGCHLD, sigchld);
|
|
||||||
extpipeactive = 0;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (pid != p)
|
|
||||||
return;
|
|
||||||
#endif // EXTERNALPIPE_PATCH
|
|
||||||
|
|
||||||
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
|
||||||
close(csdfd);
|
|
||||||
#endif // EXTERNALPIPEIN_PATCH
|
|
||||||
|
|
||||||
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
|
||||||
die("child exited with status %d\n", WEXITSTATUS(stat));
|
|
||||||
else if (WIFSIGNALED(stat))
|
|
||||||
die("child terminated due to signal %d\n", WTERMSIG(stat));
|
|
||||||
_exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -884,9 +863,7 @@ int
|
||||||
ttynew(const char *line, char *cmd, const char *out, char **args)
|
ttynew(const char *line, char *cmd, const char *out, char **args)
|
||||||
{
|
{
|
||||||
int m, s;
|
int m, s;
|
||||||
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
#endif // EXTERNALPIPEIN_PATCH
|
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
term.mode |= MODE_PRINT;
|
term.mode |= MODE_PRINT;
|
||||||
|
|
@ -944,15 +921,14 @@ ttynew(const char *line, char *cmd, const char *out, char **args)
|
||||||
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
|
||||||
csdfd = s;
|
csdfd = s;
|
||||||
cmdfd = m;
|
cmdfd = m;
|
||||||
|
#else
|
||||||
|
close(s);
|
||||||
|
cmdfd = m;
|
||||||
|
#endif // EXTERNALPIPEIN_PATCH
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_handler = sigchld;
|
sa.sa_handler = sigchld;
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
sigaction(SIGCHLD, &sa, NULL);
|
||||||
#else
|
|
||||||
close(s);
|
|
||||||
cmdfd = m;
|
|
||||||
signal(SIGCHLD, sigchld);
|
|
||||||
#endif // EXTERNALPIPEIN_PATCH
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return cmdfd;
|
return cmdfd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue