aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/unix
diff options
context:
space:
mode:
authorRyan Tilder <[email protected]>2010-08-06 15:17:52 -0700
committerBjörn Gustavsson <[email protected]>2010-09-29 16:39:05 +0200
commit94399ba3a34e90a95a03117b3a6c8daf63090235 (patch)
tree6077edbe7cbc00401e08dae8bcb5d3c6f05a8933 /erts/etc/unix
parent9b6cd9712b34a1705fc1ec2dda4878d0bbb3b1e4 (diff)
downloadotp-94399ba3a34e90a95a03117b3a6c8daf63090235.tar.gz
otp-94399ba3a34e90a95a03117b3a6c8daf63090235.tar.bz2
otp-94399ba3a34e90a95a03117b3a6c8daf63090235.zip
Add corrected support for Solaris PTYs to run_erl
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.
Diffstat (limited to 'erts/etc/unix')
-rw-r--r--erts/etc/unix/run_erl.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c
index 07d8071720..cadff12c6f 100644
--- a/erts/etc/unix/run_erl.c
+++ b/erts/etc/unix/run_erl.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1996-2009. All Rights Reserved.
+ * Copyright Ericsson AB 1996-2010. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -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 */
@@ -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) {
@@ -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");