Skip to content

Commit

Permalink
Add corrected support for Solaris PTYs to run_erl
Browse files Browse the repository at this point in the history
Two related but slightly separate issues: run_erl doesn't support Solaris's
/dev/ptmx device and run_erl didn't load the necessary STREAMS modules so that
to_erl can provide terminal echo of keyboard input.  This patch adds ifdef'd
support for Solaris and derivatives to open /dev/ptmx directly since adding
the C99 defines to CFLAGS breaks all kinds of other things in the build.  It
also adds ifdef'd ioctl calls to load the necessary STREAMS modules to permit
termios to work.
  • Loading branch information
rtilder committed Aug 6, 2010
1 parent edfe4b9 commit 06ab492
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion erts/etc/unix/run_erl.c
Expand Up @@ -75,6 +75,9 @@
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if defined(__sun) && defined(__SVR4)
# include <stropts.h>
#endif

#include "run_erl.h"
#include "safe_string.h" /* sn_printf, strn_cpy, strn_cat, etc */
Expand Down Expand Up @@ -864,8 +867,12 @@ static int open_pty_master(char **ptyslave)

/* Use the posix_openpt if working, as this guarantees creation of the
slave device properly. */
#ifdef HAVE_WORKING_POSIX_OPENPT
#if defined(HAVE_WORKING_POSIX_OPENPT) || (defined(__sun) && defined(__SVR4))
# ifdef HAVE_WORKING_POSIX_OPENPT
if ((mfd = posix_openpt(O_RDWR)) >= 0) {
# elif defined(__sun) && defined(__SVR4)
if ((mfd = open("/dev/ptmx", O_RDWR)) >= 0) {
# endif
if ((*ptyslave = ptsname(mfd)) != NULL &&
grantpt(mfd) == 0 &&
unlockpt(mfd) == 0) {
Expand Down Expand Up @@ -981,6 +988,26 @@ static int open_pty_slave(char *name)
return -1;
}

#if defined(__sun) && defined(__SVR4)
/* Load the necessary STREAMS modules for Solaris */
if ((ioctl(sfd, I_FIND, "ldterm")) < 0) {
ERROR0(LOG_ERR, "Failed to find ldterm STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ptem") < 0) {
ERROR0(LOG_ERR, "Failed to push ptem STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ldterm") < 0) {
ERROR0(LOG_ERR, "Failed to push ldterm STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ttcompat") < 0) {
ERROR0(LOG_ERR, "Failed to push ttcompat STREAMS module");
return -1;
}
#endif

#ifdef DEBUG
if (tcgetattr(sfd, &tty_rmode) < 0) {
fprintf(stderr, "Cannot get terminals current mode\n");
Expand Down

0 comments on commit 06ab492

Please sign in to comment.