mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
(init_subshell): use openpty() to open master/slave devices for subshell.
Thanks Jesse R. Gorzinski <jgorzins@us.ibm.com> for the original patch. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
3909ef1bc5
commit
a7ff88d24c
@ -24,6 +24,15 @@ AC_DEFUN([mc_SUBSHELL], [
|
||||
|
||||
if test "x$result" != xno; then
|
||||
AC_DEFINE(ENABLE_SUBSHELL, 1, [Define to enable subshell support])
|
||||
|
||||
dnl openpty() can simplify opening of master/slave devices for subshell
|
||||
AC_CHECK_HEADERS([pty.h libutil.h util.h])
|
||||
AC_CHECK_FUNCS(openpty,,
|
||||
AC_CHECK_LIB(util,openpty,
|
||||
[AC_DEFINE(HAVE_OPENPTY)
|
||||
LIBS="$LIBS -lutil"]
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([$result])
|
||||
|
@ -74,6 +74,20 @@
|
||||
#include <stropts.h> /* For I_PUSH */
|
||||
#endif /* HAVE_STROPTS_H */
|
||||
|
||||
#ifdef HAVE_OPENPTY
|
||||
/* includes for openpty() */
|
||||
#if HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
#endif
|
||||
#if HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
/* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
|
||||
#if HAVE_LIBUTIL_H
|
||||
#include <libutil.h>
|
||||
#endif
|
||||
#endif /* HAVE_OPENPTY */
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/unixcompat.h"
|
||||
@ -1026,6 +1040,15 @@ init_subshell (void)
|
||||
|
||||
/* FIXME: We may need to open a fresh pty each time on SVR4 */
|
||||
|
||||
#ifdef HAVE_OPENPTY
|
||||
if (openpty (&mc_global.tty.subshell_pty, &subshell_pty_slave, NULL, NULL, NULL))
|
||||
{
|
||||
fprintf (stderr, "Cannot open master and slave sides of pty: %s\n",
|
||||
unix_error_string (errno));
|
||||
mc_global.tty.use_subshell = FALSE;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
mc_global.tty.subshell_pty = pty_open_master (pty_name);
|
||||
if (mc_global.tty.subshell_pty == -1)
|
||||
{
|
||||
@ -1041,6 +1064,7 @@ init_subshell (void)
|
||||
mc_global.tty.use_subshell = FALSE;
|
||||
return;
|
||||
}
|
||||
#endif /* HAVE_OPENPTY */
|
||||
|
||||
/* Create a pipe for receiving the subshell's CWD */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user