dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 2ca3eda7906809958c5b4b8c83913932a4266040
parent 4e058320b8d36dab239e4e497b3913d4977f8141
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue,  8 Jul 2014 22:45:39 +0200

Streamline forkpty-aix.c

Diffstat:
forkpty-aix.c | 34++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/forkpty-aix.c b/forkpty-aix.c @@ -17,23 +17,13 @@ #include <sys/types.h> #include <sys/ioctl.h> - #include <fcntl.h> #include <stdlib.h> #include <stropts.h> #include <unistd.h> #include <paths.h> -/* Fatal errors. */ -#ifdef NDEBUG - #define debug(format, args...) -#else - #define debug eprint -#endif -#define fatal(msg) debug("%s: %s", __func__, msg); - -pid_t -forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) +pid_t forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) { int slave, fd; char *path; @@ -41,7 +31,7 @@ forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) struct termios tio2; if ((*master = open("/dev/ptc", O_RDWR|O_NOCTTY)) == -1) - return (-1); + return -1; if ((path = ttyname(*master)) == NULL) goto out; @@ -61,47 +51,47 @@ forkpty(int *master, char *name, struct termios *tio, struct winsize *ws) } if (setsid() < 0) - fatal("setsid"); + return -1; fd = open(_PATH_TTY, O_RDWR|O_NOCTTY); if (fd >= 0) - fatal("open succeeded (failed to disconnect)"); + return -1; fd = open(path, O_RDWR); if (fd < 0) - fatal("open failed"); + return -1; close(fd); fd = open("/dev/tty", O_WRONLY); if (fd < 0) - fatal("open failed"); + return -1; close(fd); if (tcgetattr(slave, &tio2) != 0) - fatal("tcgetattr failed"); + return -1; if (tio != NULL) memcpy(tio2.c_cc, tio->c_cc, sizeof tio2.c_cc); tio2.c_cc[VERASE] = '\177'; if (tcsetattr(slave, TCSAFLUSH, &tio2) == -1) - fatal("tcsetattr failed"); + return -1; if (ioctl(slave, TIOCSWINSZ, ws) == -1) - fatal("ioctl failed"); + return -1; dup2(slave, 0); dup2(slave, 1); dup2(slave, 2); if (slave > 2) close(slave); - return (0); + return 0; } close(slave); - return (pid); + return pid; out: if (*master != -1) close(*master); if (slave != -1) close(slave); - return (-1); + return -1; }