From 3f38a10a2ecab201b5c70caa8386003bcb351a1b Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Tue, 15 Apr 2014 13:09:05 +0200 Subject: [PATCH] Implement CTTY grabbing when TIOCSCTTY is missing AIX is missing TIOCSCTTY, so we assign us a ctty via a open of the slave device. Signed-off-by: Anton Lundin --- src/util/pty_compat.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util/pty_compat.cc b/src/util/pty_compat.cc index 25c0abf..c723326 100644 --- a/src/util/pty_compat.cc +++ b/src/util/pty_compat.cc @@ -140,12 +140,22 @@ pid_t my_forkpty( int *amaster, char *name, case 0: /* Child */ if ( setsid() < 0 ) perror( "setsid" ); -#ifndef _AIX +#ifdef TIOCSCTTY if ( ioctl( slave, TIOCSCTTY, NULL ) < 0 ) { perror( "ioctl" ); return -1; } -#endif +#else + { + int dummy_fd; + dummy_fd = open (slave_name, O_RDWR); + if (dummy_fd < 0) { + perror( "open(slave_name)" ); + return -1; + } + close (dummy_fd); + } +#endif /* TIOCSCTTY */ close( master ); dup2( slave, STDIN_FILENO ); dup2( slave, STDOUT_FILENO );