diff options
-rw-r--r-- | st.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -513,7 +513,7 @@ static STREscape strescseq; | |||
513 | static int cmdfd; | 513 | static int cmdfd; |
514 | static pid_t pid; | 514 | static pid_t pid; |
515 | static Selection sel; | 515 | static Selection sel; |
516 | static int iofd = STDOUT_FILENO; | 516 | static int iofd = 1; |
517 | static char **opt_cmd = NULL; | 517 | static char **opt_cmd = NULL; |
518 | static char *opt_io = NULL; | 518 | static char *opt_io = NULL; |
519 | static char *opt_title = NULL; | 519 | static char *opt_title = NULL; |
@@ -1207,7 +1207,7 @@ die(const char *errstr, ...) { | |||
1207 | va_start(ap, errstr); | 1207 | va_start(ap, errstr); |
1208 | vfprintf(stderr, errstr, ap); | 1208 | vfprintf(stderr, errstr, ap); |
1209 | va_end(ap); | 1209 | va_end(ap); |
1210 | exit(EXIT_FAILURE); | 1210 | exit(1); |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | void | 1213 | void |
@@ -1256,12 +1256,12 @@ execsh(void) { | |||
1256 | signal(SIGALRM, SIG_DFL); | 1256 | signal(SIGALRM, SIG_DFL); |
1257 | 1257 | ||
1258 | execvp(prog, args); | 1258 | execvp(prog, args); |
1259 | _exit(EXIT_FAILURE); | 1259 | _exit(1); |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | void | 1262 | void |
1263 | sigchld(int a) { | 1263 | sigchld(int a) { |
1264 | int stat, ret; | 1264 | int stat; |
1265 | pid_t p; | 1265 | pid_t p; |
1266 | 1266 | ||
1267 | if((p = waitpid(pid, &stat, WNOHANG)) < 0) | 1267 | if((p = waitpid(pid, &stat, WNOHANG)) < 0) |
@@ -1270,10 +1270,9 @@ sigchld(int a) { | |||
1270 | if(pid != p) | 1270 | if(pid != p) |
1271 | return; | 1271 | return; |
1272 | 1272 | ||
1273 | ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE; | 1273 | if (!WIFEXITED(stat) || WEXITSTATUS(stat)) |
1274 | if (ret != EXIT_SUCCESS) | ||
1275 | die("child finished with error '%d'\n", stat); | 1274 | die("child finished with error '%d'\n", stat); |
1276 | exit(EXIT_SUCCESS); | 1275 | exit(0); |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | 1278 | ||
@@ -1309,8 +1308,7 @@ ttynew(void) { | |||
1309 | if(opt_io) { | 1308 | if(opt_io) { |
1310 | term.mode |= MODE_PRINT; | 1309 | term.mode |= MODE_PRINT; |
1311 | iofd = (!strcmp(opt_io, "-")) ? | 1310 | iofd = (!strcmp(opt_io, "-")) ? |
1312 | STDOUT_FILENO : | 1311 | 1 : open(opt_io, O_WRONLY | O_CREAT, 0666); |
1313 | open(opt_io, O_WRONLY | O_CREAT, 0666); | ||
1314 | if(iofd < 0) { | 1312 | if(iofd < 0) { |
1315 | fprintf(stderr, "Error opening %s:%s\n", | 1313 | fprintf(stderr, "Error opening %s:%s\n", |
1316 | opt_io, strerror(errno)); | 1314 | opt_io, strerror(errno)); |
@@ -1320,7 +1318,7 @@ ttynew(void) { | |||
1320 | if (opt_line) { | 1318 | if (opt_line) { |
1321 | if((cmdfd = open(opt_line, O_RDWR)) < 0) | 1319 | if((cmdfd = open(opt_line, O_RDWR)) < 0) |
1322 | die("open line failed: %s\n", strerror(errno)); | 1320 | die("open line failed: %s\n", strerror(errno)); |
1323 | close(STDIN_FILENO); | 1321 | close(0); |
1324 | dup(cmdfd); | 1322 | dup(cmdfd); |
1325 | stty(); | 1323 | stty(); |
1326 | return; | 1324 | return; |
@@ -1337,9 +1335,9 @@ ttynew(void) { | |||
1337 | case 0: | 1335 | case 0: |
1338 | close(iofd); | 1336 | close(iofd); |
1339 | setsid(); /* create a new process group */ | 1337 | setsid(); /* create a new process group */ |
1340 | dup2(s, STDIN_FILENO); | 1338 | dup2(s, 0); |
1341 | dup2(s, STDOUT_FILENO); | 1339 | dup2(s, 1); |
1342 | dup2(s, STDERR_FILENO); | 1340 | dup2(s, 2); |
1343 | if(ioctl(s, TIOCSCTTY, NULL) < 0) | 1341 | if(ioctl(s, TIOCSCTTY, NULL) < 0) |
1344 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); | 1342 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); |
1345 | close(s); | 1343 | close(s); |
@@ -3871,7 +3869,7 @@ cmessage(XEvent *e) { | |||
3871 | } else if(e->xclient.data.l[0] == xw.wmdeletewin) { | 3869 | } else if(e->xclient.data.l[0] == xw.wmdeletewin) { |
3872 | /* Send SIGHUP to shell */ | 3870 | /* Send SIGHUP to shell */ |
3873 | kill(pid, SIGHUP); | 3871 | kill(pid, SIGHUP); |
3874 | exit(EXIT_SUCCESS); | 3872 | exit(0); |
3875 | } | 3873 | } |
3876 | } | 3874 | } |
3877 | 3875 | ||