diff --git a/ChangeLog b/ChangeLog index 4fbc8457a18..d111e9f6319 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,8 @@ (BROKEN_FIONREAD, BROKEN_PTY_READ_AFTER_EAGAIN, BROKEN_SIGAIO) (BROKEN_SIGPOLL, BROKEN_SIGPTY, FIRST_PTY_LETTER) (G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION, PTY_OPEN) - (RUN_TIME_REMAP, SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP + (PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF, RUN_TIME_REMAP) + (SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP) (XOS_NEEDS_TIME_H): Move here from src/s. 2012-07-11 Glenn Morris diff --git a/configure.ac b/configure.ac index c9a97d9f282..191d2ae7e05 100644 --- a/configure.ac +++ b/configure.ac @@ -3299,16 +3299,26 @@ dnl trying suffixes 0-16. AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of first PTY, if PTYs are supported.]) AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.]) +AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control + end of a PTY, if non-standard.]) +AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty + end of a PTY, if non-standard.]) case $opsys in aix4-2 ) AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)] ) + dnl You allocate a pty by opening /dev/ptc to get the master side. + dnl To get the name of the slave side, you just ttyname() the master side. + AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");] ) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));] ) ;; cygwin ) AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] ) dnl multi-line AC_DEFINEs are hard. :( AC_DEFINE(PTY_OPEN, [ do { int dummy; SIGMASKTYPE mask; mask = sigblock (sigmask (SIGCHLD)); if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) fd = -1; sigsetmask (mask); if (fd >= 0) emacs_close (dummy); } while (0)] ) + AC_DEFINE(PTY_NAME_SPRINTF, [] ) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] ) ;; darwin ) @@ -3319,9 +3329,11 @@ case $opsys in dnl But we don't have to block SIGCHLD because it is blocked in the dnl implementation of grantpt. AC_DEFINE(PTY_OPEN, [ do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)] ) + AC_DEFINE(PTY_NAME_SPRINTF, [] ) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] ) ;; - gnu | hpux* | freebsd | netbsd | openbsd ) + gnu | freebsd | netbsd | openbsd ) AC_DEFINE(FIRST_PTY_LETTER, ['p']) ;; @@ -3329,15 +3341,27 @@ case $opsys in dnl if HAVE_GRANTPT if test "x$ac_cv_func_grantpt" = xyes; then AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] ) + dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD + dnl to prevent sigchld_handler from intercepting the child's death. + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname; sigblock (sigmask (SIGCHLD)); if (grantpt (fd) == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname(fd))) { sigunblock (sigmask (SIGCHLD)); close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); sigunblock (sigmask (SIGCHLD)); }] ) dnl if HAVE_GETPT if test "x$ac_cv_func_getpt" = xyes; then AC_DEFINE(PTY_OPEN, [fd = getpt ()]) + AC_DEFINE(PTY_NAME_SPRINTF, [] ) + else + AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] ) fi else AC_DEFINE(FIRST_PTY_LETTER, ['p']) fi ;; + hpux*) + AC_DEFINE(FIRST_PTY_LETTER, ['p']) + AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);] ) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);] ) + ;; + irix6-5 ) dnl It looks like this cannot be right, because it is not a loop. dnl However, process.c actually does this: @@ -3353,12 +3377,31 @@ case $opsys in dnl Not used, because PTY_ITERATION is defined. AC_DEFINE(FIRST_PTY_LETTER, ['q']) AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }] ) + dnl No need to get the pty name at all. + AC_DEFINE(PTY_NAME_SPRINTF, [] ) + dnl No need to use sprintf to get the tty name--we get that from _getpty. + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [] ) ;; - sol2* | unixware ) + sol2* ) dnl This change means that we don't loop through allocate_pty too dnl many times in the (rare) event of a failure. AC_DEFINE(FIRST_PTY_LETTER, ['z']) + AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] ) + dnl Uses sigblock/sigunblock rather than sighold/sigrelse, + dnl which appear to be BSD4.1 specific. It may also be appropriate + dnl for SVR4.x (x<2) but I'm not sure. fnf@cygnus.com + dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() + dnl from intercepting that death. If any child but grantpt's should die + dnl within, it should be caught after sigrelse(2). + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; sigblock (sigmask (SIGCLD)); if (grantpt (fd) == -1) { emacs_close (fd); return -1; } sigunblock (sigmask (SIGCLD)); if (unlockpt (fd) == -1) { emacs_close (fd); return -1; } if (!(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }] ) + ;; + + dnl Comments are as per sol2*. + unixware ) + AC_DEFINE(FIRST_PTY_LETTER, ['z']) + AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");] ) + AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; sigblock(sigmask(SIGCLD)); if (grantpt(fd) == -1) fatal("could not grant slave pty"); sigunblock(sigmask(SIGCLD)); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }] ) ;; esac diff --git a/src/ChangeLog b/src/ChangeLog index 8ba63959ba4..804da9c2eef 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2012-07-12 Glenn Morris + * src/s/aix4-2.h, src/s/cygwin.h, src/s/darwin.h: + * src/s/gnu-linux.h, src/s/hpux10-20.h, src/s/irix6-5.h: + * src/s/sol2-6.h, src/s/unixware.h, src/s/usg5-4-common.h: + Move PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF to configure. + * s/cygwin.h, s/darwin.h, s/gnu-linux.h, s/irix6-5.h: Move PTY_OPEN to configure. diff --git a/src/s/aix4-2.h b/src/s/aix4-2.h index 326d7217acb..49eabfc8466 100644 --- a/src/s/aix4-2.h +++ b/src/s/aix4-2.h @@ -26,11 +26,6 @@ along with GNU Emacs. If not, see . */ #define _AIX #endif -/* In AIX, you allocate a pty by opening /dev/ptc to get the master side. - To get the name of the slave side, you just ttyname() the master side. */ -#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptc"); -#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd)); - /* Special items needed to make Emacs run on this system. */ diff --git a/src/s/cygwin.h b/src/s/cygwin.h index 79a8999b034..7c32fd3f90d 100644 --- a/src/s/cygwin.h +++ b/src/s/cygwin.h @@ -17,8 +17,5 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ -#define PTY_NAME_SPRINTF /* none */ -#define PTY_TTY_NAME_SPRINTF /* none */ - /* Used in various places to enable cygwin-specific code changes. */ #define CYGWIN 1 diff --git a/src/s/darwin.h b/src/s/darwin.h index 569b24e3a6e..c853f9d94f0 100644 --- a/src/s/darwin.h +++ b/src/s/darwin.h @@ -30,9 +30,6 @@ along with GNU Emacs. If not, see . */ distinguish OS X from pure Darwin. */ #define DARWIN_OS -#define PTY_NAME_SPRINTF /* none */ -#define PTY_TTY_NAME_SPRINTF /* none */ - /* PTYs only work correctly on Darwin 7 or higher. So make the default for process-connection-type dependent on the kernel version. */ #define MIN_PTY_KERNEL_VERSION '7' diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h index 20a2354a2ab..626113b119c 100644 --- a/src/s/gnu-linux.h +++ b/src/s/gnu-linux.h @@ -27,31 +27,6 @@ along with GNU Emacs. If not, see . */ #if defined HAVE_GRANTPT #define UNIX98_PTYS - -#ifdef HAVE_GETPT -#define PTY_NAME_SPRINTF -#else /* not HAVE_GETPT */ -#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx"); -#endif /* not HAVE_GETPT */ - -/* Note that grantpt and unlockpt may fork. We must block SIGCHLD to - prevent sigchld_handler from intercepting the child's death. */ -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptyname; \ - \ - sigblock (sigmask (SIGCHLD)); \ - if (grantpt (fd) == -1 || unlockpt (fd) == -1 \ - || !(ptyname = ptsname(fd))) \ - { \ - sigunblock (sigmask (SIGCHLD)); \ - close (fd); \ - return -1; \ - } \ - snprintf (pty_name, sizeof pty_name, "%s", ptyname); \ - sigunblock (sigmask (SIGCHLD)); \ - } - #endif /* HAVE_GRANTPT */ /* Here, on a separate page, add any special hacks needed diff --git a/src/s/hpux10-20.h b/src/s/hpux10-20.h index bb81eb800e4..b9a1d8edab8 100644 --- a/src/s/hpux10-20.h +++ b/src/s/hpux10-20.h @@ -26,14 +26,6 @@ along with GNU Emacs. If not, see . */ /* Special hacks needed to make Emacs run on this system. */ -/* This is how to get the device name of the tty end of a pty. */ -#define PTY_TTY_NAME_SPRINTF \ - sprintf (pty_name, "/dev/pty/tty%c%x", c, i); - -/* This is how to get the device name of the control end of a pty. */ -#define PTY_NAME_SPRINTF \ - sprintf (pty_name, "/dev/ptym/pty%c%x", c, i); - /* Assar Westerlund says this is necessary for HP-UX 10.20, and that it works for HP-UX 0 as well. */ #define NO_EDITRES diff --git a/src/s/irix6-5.h b/src/s/irix6-5.h index b053634d17c..39ac59a00c2 100644 --- a/src/s/irix6-5.h +++ b/src/s/irix6-5.h @@ -26,11 +26,6 @@ along with GNU Emacs. If not, see . */ #undef SETUP_SLAVE_PTY -/* No need to use sprintf to get the tty name--we get that from _getpty. */ -#define PTY_TTY_NAME_SPRINTF -/* No need to get the pty name at all. */ -#undef PTY_NAME_SPRINTF -#define PTY_NAME_SPRINTF #ifdef emacs char *_getpty(); #endif diff --git a/src/s/sol2-6.h b/src/s/sol2-6.h index e77d9e5a901..ff6cfc277cc 100644 --- a/src/s/sol2-6.h +++ b/src/s/sol2-6.h @@ -21,28 +21,4 @@ along with GNU Emacs. If not, see . */ #define SOLARIS2 -/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock - rather than sighold/sigrelse, which appear to be BSD4.1 specific. - It may also be appropriate for SVR4.x - (x<2) but I'm not sure. fnf@cygnus.com */ -/* This sets the name of the slave side of the PTY. On SysVr4, - grantpt(3) forks a subprocess, so keep sigchld_handler() from - intercepting that death. If any child but grantpt's should die - within, it should be caught after sigrelse(2). */ - -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptsname (int), *ptyname; \ - \ - sigblock (sigmask (SIGCLD)); \ - if (grantpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - sigunblock (sigmask (SIGCLD)); \ - if (unlockpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - if (!(ptyname = ptsname (fd))) \ - { emacs_close (fd); return -1; } \ - snprintf (pty_name, sizeof pty_name, "%s", ptyname); \ - } - #define GC_SETJMP_WORKS 1 diff --git a/src/s/unixware.h b/src/s/unixware.h index 5bda987ffe1..f42e6363245 100644 --- a/src/s/unixware.h +++ b/src/s/unixware.h @@ -20,29 +20,6 @@ along with GNU Emacs. If not, see . */ #include "usg5-4-common.h" -/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock - rather than sighold/sigrelse, which appear to be BSD4.1 specific. - It may also be appropriate for SVR4.x - (x<2) but I'm not sure. fnf@cygnus.com */ -/* This sets the name of the slave side of the PTY. On SysVr4, - grantpt(3) forks a subprocess, so keep sigchld_handler() from - intercepting that death. If any child but grantpt's should die - within, it should be caught after sigrelse(2). */ -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptsname (int), *ptyname; \ - \ - sigblock(sigmask(SIGCLD)); \ - if (grantpt(fd) == -1) \ - fatal("could not grant slave pty"); \ - sigunblock(sigmask(SIGCLD)); \ - if (unlockpt(fd) == -1) \ - fatal("could not unlock slave pty"); \ - if (!(ptyname = ptsname(fd))) \ - fatal ("could not enable slave pty"); \ - snprintf (pty_name, sizeof pty_name, "%s", ptyname); \ - } - /* Conservative garbage collection has not been tested, so for now play it safe and stick with the old-fashioned way of marking. */ #define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE diff --git a/src/s/usg5-4-common.h b/src/s/usg5-4-common.h index 94d83dd81ef..3d3cea803dc 100644 --- a/src/s/usg5-4-common.h +++ b/src/s/usg5-4-common.h @@ -64,9 +64,6 @@ along with GNU Emacs. If not, see . */ this is all we need. */ #define TIOCSIGSEND TIOCSIGNAL -/* This sets the name of the master side of the PTY. */ -#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx"); - /* Push various streams modules onto a PTY channel. */ #define SETUP_SLAVE_PTY \ if (ioctl (xforkin, I_PUSH, "ptem") == -1) \