diff options
author | Ed Schouten <ed@80386.nl> | 2011-10-12 20:53:21 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-10-13 17:59:50 -0700 |
commit | 525785fd7beca872ebeeb8bb6c22d82459128788 (patch) | |
tree | 66bc4342688dfe62dd6694f74ebe76400401d3ab | |
parent | 82bec8b84d90d37f75f10b3abe9ec34a3415a622 (diff) |
Add support for posix_openpt().
Instead of opening /dev/ptmx directly, we should use the proper
posix_openpt() function to obtain a pseudo-terminal. Some operating
systems, such as FreeBSD 8 and later, implement pseudo-terminal master
device nodes as a special file descriptor type, like sockets. They do
not support creation of pseudo-terminals through /dev/ptmx.
Signed-off-by: Ed Schouten <ed@80386.nl>
Reviewed-by: Guillem Jover <guillem@hadrons.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | sys.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index c3cd947..e9a5984 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ AC_CANONICAL_HOST AC_CHECK_HEADERS([pty.h stropts.h sys/param.h sys/select.h]) -AC_CHECK_FUNCS([select grantpt]) +AC_CHECK_FUNCS([select grantpt posix_openpt]) AC_ARG_WITH(localealiasfile, AS_HELP_STRING([--with-localealiasfile=<path>], @@ -335,7 +335,11 @@ allocatePty(int *pty_return, char **line_return) #if defined(HAVE_GRANTPT) int rc; +#ifdef HAVE_POSIX_OPENPT + pty = posix_openpt(O_RDWR); +#else pty = open("/dev/ptmx", O_RDWR); +#endif if (pty < 0) goto bsd; |