Any system having different assignments than the usual 0, 1, 2 for
the standard file numbers and 0, 1 for the exit-statuses is broken
beyond repair.
Let's keep it simple and just use the numbers, no reason to fall
out of the window here and bend down for POSIX.
In one occasion, the ret-variable was not necessary. The check was
rewritten.
Signed-off-by: Christoph Lohmann <[email protected]>
static int cmdfd;
static pid_t pid;
static Selection sel;
static int cmdfd;
static pid_t pid;
static Selection sel;
-static int iofd = STDOUT_FILENO;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
signal(SIGALRM, SIG_DFL);
execvp(prog, args);
signal(SIGALRM, SIG_DFL);
execvp(prog, args);
pid_t p;
if((p = waitpid(pid, &stat, WNOHANG)) < 0)
pid_t p;
if((p = waitpid(pid, &stat, WNOHANG)) < 0)
- ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE;
- if (ret != EXIT_SUCCESS)
+ if (!WIFEXITED(stat) || WEXITSTATUS(stat))
die("child finished with error '%d'\n", stat);
die("child finished with error '%d'\n", stat);
if(opt_io) {
term.mode |= MODE_PRINT;
iofd = (!strcmp(opt_io, "-")) ?
if(opt_io) {
term.mode |= MODE_PRINT;
iofd = (!strcmp(opt_io, "-")) ?
- STDOUT_FILENO :
- open(opt_io, O_WRONLY | O_CREAT, 0666);
+ 1 : open(opt_io, O_WRONLY | O_CREAT, 0666);
if(iofd < 0) {
fprintf(stderr, "Error opening %s:%s\n",
opt_io, strerror(errno));
if(iofd < 0) {
fprintf(stderr, "Error opening %s:%s\n",
opt_io, strerror(errno));
if (opt_line) {
if((cmdfd = open(opt_line, O_RDWR)) < 0)
die("open line failed: %s\n", strerror(errno));
if (opt_line) {
if((cmdfd = open(opt_line, O_RDWR)) < 0)
die("open line failed: %s\n", strerror(errno));
dup(cmdfd);
stty();
return;
dup(cmdfd);
stty();
return;
case 0:
close(iofd);
setsid(); /* create a new process group */
case 0:
close(iofd);
setsid(); /* create a new process group */
- dup2(s, STDIN_FILENO);
- dup2(s, STDOUT_FILENO);
- dup2(s, STDERR_FILENO);
+ dup2(s, 0);
+ dup2(s, 1);
+ dup2(s, 2);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s);
} else if(e->xclient.data.l[0] == xw.wmdeletewin) {
/* Send SIGHUP to shell */
kill(pid, SIGHUP);
} else if(e->xclient.data.l[0] == xw.wmdeletewin) {
/* Send SIGHUP to shell */
kill(pid, SIGHUP);