aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/st.c b/st.c
index e510565..e017940 100644
--- a/st.c
+++ b/st.c
@@ -65,7 +65,6 @@ char *argv0;
65#define REDRAW_TIMEOUT (80*1000) /* 80 ms */ 65#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
66 66
67/* macros */ 67/* macros */
68#define SERRNO strerror(errno)
69#define MIN(a, b) ((a) < (b) ? (a) : (b)) 68#define MIN(a, b) ((a) < (b) ? (a) : (b))
70#define MAX(a, b) ((a) < (b) ? (b) : (a)) 69#define MAX(a, b) ((a) < (b) ? (b) : (a))
71#define LEN(a) (sizeof(a) / sizeof(a[0])) 70#define LEN(a) (sizeof(a) / sizeof(a[0]))
@@ -1181,7 +1180,7 @@ sigchld(int a) {
1181 int stat = 0; 1180 int stat = 0;
1182 1181
1183 if(waitpid(pid, &stat, 0) < 0) 1182 if(waitpid(pid, &stat, 0) < 0)
1184 die("Waiting for pid %hd failed: %s\n", pid, SERRNO); 1183 die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
1185 1184
1186 if(WIFEXITED(stat)) { 1185 if(WIFEXITED(stat)) {
1187 exit(WEXITSTATUS(stat)); 1186 exit(WEXITSTATUS(stat));
@@ -1197,7 +1196,7 @@ ttynew(void) {
1197 1196
1198 /* seems to work fine on linux, openbsd and freebsd */ 1197 /* seems to work fine on linux, openbsd and freebsd */
1199 if(openpty(&m, &s, NULL, NULL, &w) < 0) 1198 if(openpty(&m, &s, NULL, NULL, &w) < 0)
1200 die("openpty failed: %s\n", SERRNO); 1199 die("openpty failed: %s\n", strerror(errno));
1201 1200
1202 switch(pid = fork()) { 1201 switch(pid = fork()) {
1203 case -1: 1202 case -1:
@@ -1209,7 +1208,7 @@ ttynew(void) {
1209 dup2(s, STDOUT_FILENO); 1208 dup2(s, STDOUT_FILENO);
1210 dup2(s, STDERR_FILENO); 1209 dup2(s, STDERR_FILENO);
1211 if(ioctl(s, TIOCSCTTY, NULL) < 0) 1210 if(ioctl(s, TIOCSCTTY, NULL) < 0)
1212 die("ioctl TIOCSCTTY failed: %s\n", SERRNO); 1211 die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
1213 close(s); 1212 close(s);
1214 close(m); 1213 close(m);
1215 execsh(); 1214 execsh();
@@ -1252,7 +1251,7 @@ ttyread(void) {
1252 1251
1253 /* append read bytes to unprocessed bytes */ 1252 /* append read bytes to unprocessed bytes */
1254 if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) 1253 if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
1255 die("Couldn't read from shell: %s\n", SERRNO); 1254 die("Couldn't read from shell: %s\n", strerror(errno));
1256 1255
1257 /* process every complete utf8 char */ 1256 /* process every complete utf8 char */
1258 buflen += ret; 1257 buflen += ret;
@@ -1271,7 +1270,7 @@ ttyread(void) {
1271void 1270void
1272ttywrite(const char *s, size_t n) { 1271ttywrite(const char *s, size_t n) {
1273 if(write(cmdfd, s, n) == -1) 1272 if(write(cmdfd, s, n) == -1)
1274 die("write error on tty: %s\n", SERRNO); 1273 die("write error on tty: %s\n", strerror(errno));
1275} 1274}
1276 1275
1277void 1276void
@@ -1290,7 +1289,7 @@ ttyresize(void) {
1290 w.ws_xpixel = xw.tw; 1289 w.ws_xpixel = xw.tw;
1291 w.ws_ypixel = xw.th; 1290 w.ws_ypixel = xw.th;
1292 if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0) 1291 if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
1293 fprintf(stderr, "Couldn't set window size: %s\n", SERRNO); 1292 fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno));
1294} 1293}
1295 1294
1296int 1295int
@@ -3750,7 +3749,7 @@ run(void) {
3750 if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) { 3749 if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) {
3751 if(errno == EINTR) 3750 if(errno == EINTR)
3752 continue; 3751 continue;
3753 die("select failed: %s\n", SERRNO); 3752 die("select failed: %s\n", strerror(errno));
3754 } 3753 }
3755 if(FD_ISSET(cmdfd, &rfd)) { 3754 if(FD_ISSET(cmdfd, &rfd)) {
3756 ttyread(); 3755 ttyread();