diff options
Diffstat (limited to '')
| -rw-r--r-- | st.c | 21 |
1 files changed, 11 insertions, 10 deletions
| @@ -256,10 +256,10 @@ xwrite(int fd, const char *s, size_t len) | |||
| 256 | void * | 256 | void * |
| 257 | xmalloc(size_t len) | 257 | xmalloc(size_t len) |
| 258 | { | 258 | { |
| 259 | void *p = malloc(len); | 259 | void *p; |
| 260 | 260 | ||
| 261 | if (!p) | 261 | if (!(p = malloc(len))) |
| 262 | die("Out of memory\n"); | 262 | die("malloc: %s\n", strerror(errno)); |
| 263 | 263 | ||
| 264 | return p; | 264 | return p; |
| 265 | } | 265 | } |
| @@ -268,7 +268,7 @@ void * | |||
| 268 | xrealloc(void *p, size_t len) | 268 | xrealloc(void *p, size_t len) |
| 269 | { | 269 | { |
| 270 | if ((p = realloc(p, len)) == NULL) | 270 | if ((p = realloc(p, len)) == NULL) |
| 271 | die("Out of memory\n"); | 271 | die("realloc: %s\n", strerror(errno)); |
| 272 | 272 | ||
| 273 | return p; | 273 | return p; |
| 274 | } | 274 | } |
| @@ -277,7 +277,7 @@ char * | |||
| 277 | xstrdup(char *s) | 277 | xstrdup(char *s) |
| 278 | { | 278 | { |
| 279 | if ((s = strdup(s)) == NULL) | 279 | if ((s = strdup(s)) == NULL) |
| 280 | die("Out of memory\n"); | 280 | die("strdup: %s\n", strerror(errno)); |
| 281 | 281 | ||
| 282 | return s; | 282 | return s; |
| 283 | } | 283 | } |
| @@ -687,7 +687,7 @@ execsh(char *cmd, char **args) | |||
| 687 | errno = 0; | 687 | errno = 0; |
| 688 | if ((pw = getpwuid(getuid())) == NULL) { | 688 | if ((pw = getpwuid(getuid())) == NULL) { |
| 689 | if (errno) | 689 | if (errno) |
| 690 | die("getpwuid:%s\n", strerror(errno)); | 690 | die("getpwuid: %s\n", strerror(errno)); |
| 691 | else | 691 | else |
| 692 | die("who are you?\n"); | 692 | die("who are you?\n"); |
| 693 | } | 693 | } |
| @@ -730,7 +730,7 @@ sigchld(int a) | |||
| 730 | pid_t p; | 730 | pid_t p; |
| 731 | 731 | ||
| 732 | if ((p = waitpid(pid, &stat, WNOHANG)) < 0) | 732 | if ((p = waitpid(pid, &stat, WNOHANG)) < 0) |
| 733 | die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); | 733 | die("waiting for pid %hd failed: %s\n", pid, strerror(errno)); |
| 734 | 734 | ||
| 735 | if (pid != p) | 735 | if (pid != p) |
| 736 | return; | 736 | return; |
| @@ -781,7 +781,8 @@ ttynew(char *line, char *cmd, char *out, char **args) | |||
| 781 | 781 | ||
| 782 | if (line) { | 782 | if (line) { |
| 783 | if ((cmdfd = open(line, O_RDWR)) < 0) | 783 | if ((cmdfd = open(line, O_RDWR)) < 0) |
| 784 | die("open line failed: %s\n", strerror(errno)); | 784 | die("open line '%s' failed: %s\n", |
| 785 | line, strerror(errno)); | ||
| 785 | dup2(cmdfd, 0); | 786 | dup2(cmdfd, 0); |
| 786 | stty(args); | 787 | stty(args); |
| 787 | return cmdfd; | 788 | return cmdfd; |
| @@ -793,7 +794,7 @@ ttynew(char *line, char *cmd, char *out, char **args) | |||
| 793 | 794 | ||
| 794 | switch (pid = fork()) { | 795 | switch (pid = fork()) { |
| 795 | case -1: | 796 | case -1: |
| 796 | die("fork failed\n"); | 797 | die("fork failed: %s\n", strerror(errno)); |
| 797 | break; | 798 | break; |
| 798 | case 0: | 799 | case 0: |
| 799 | close(iofd); | 800 | close(iofd); |
| @@ -826,7 +827,7 @@ ttyread(void) | |||
| 826 | 827 | ||
| 827 | /* append read bytes to unprocessed bytes */ | 828 | /* append read bytes to unprocessed bytes */ |
| 828 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) | 829 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) |
| 829 | die("Couldn't read from shell: %s\n", strerror(errno)); | 830 | die("couldn't read from shell: %s\n", strerror(errno)); |
| 830 | buflen += ret; | 831 | buflen += ret; |
| 831 | 832 | ||
| 832 | written = twrite(buf, buflen, 0); | 833 | written = twrite(buf, buflen, 0); |
