From 9b6cd9712b34a1705fc1ec2dda4878d0bbb3b1e4 Mon Sep 17 00:00:00 2001 From: Ryan Tilder Date: Fri, 6 Aug 2010 15:07:32 -0700 Subject: Fix a typo that leads to syntax errors with DEBUG defined in run_erl While attempting to debug odd terminal echo issues on Solaris, I noticed that run_erl.c will fail to compile due to a typo causing a syntax error. --- erts/etc/unix/run_erl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c index 4bb148df98..07d8071720 100644 --- a/erts/etc/unix/run_erl.c +++ b/erts/etc/unix/run_erl.c @@ -982,7 +982,7 @@ static int open_pty_slave(char *name) } #ifdef DEBUG - if (tcgetattr(sfd, &tty_rmode) , 0) { + if (tcgetattr(sfd, &tty_rmode) < 0) { fprintf(stderr, "Cannot get terminals current mode\n"); exit(-1); } -- cgit v1.2.3 From 94399ba3a34e90a95a03117b3a6c8daf63090235 Mon Sep 17 00:00:00 2001 From: Ryan Tilder Date: Fri, 6 Aug 2010 15:17:52 -0700 Subject: 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. --- erts/etc/unix/run_erl.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'erts') 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 #endif +#if defined(__sun) && defined(__SVR4) +# include +#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"); -- cgit v1.2.3