* configure.ac (PTY_OPEN) Move here from src/s.
* src/s/cygwin.h, src/s/darwin.h, src/s/gnu-linux.h, src/s/irix6-5.h:
Move PTY_OPEN to configure.
* configure.ac (NARROWPROTO, NO_ABORT, BROKEN_GET_CURRENT_DIR_NAME)
(BROKEN_FIONREAD, BROKEN_PTY_READ_AFTER_EAGAIN, BROKEN_SIGAIO)
(BROKEN_SIGPOLL, BROKEN_SIGPTY, FIRST_PTY_LETTER)
- (G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION)
+ (G_SLICE_ALWAYS_MALLOC, PREFER_VSUSP, PTY_ITERATION, PTY_OPEN)
(RUN_TIME_REMAP, SETPGRP_RELEASES_CTTY, TAB3, TABDLY, RUN_TIME_REMAP
(XOS_NEEDS_TIME_H): Move here from src/s.
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.])
case $opsys in
aix4-2 )
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)] )
;;
darwin )
AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)] )
dnl Not used, because PTY_ITERATION is defined.
AC_DEFINE(FIRST_PTY_LETTER, ['p'])
+ dnl Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8.
+ 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)] )
;;
gnu | hpux* | freebsd | netbsd | openbsd )
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 if HAVE_GETPT
+ if test "x$ac_cv_func_getpt" = xyes; then
+ AC_DEFINE(PTY_OPEN, [fd = getpt ()])
+ fi
else
AC_DEFINE(FIRST_PTY_LETTER, ['p'])
fi
AC_DEFINE(PTY_ITERATION, [])
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); }] )
;;
sol2* | unixware )
2012-07-12 Glenn Morris <rgm@gnu.org>
+ * s/cygwin.h, s/darwin.h, s/gnu-linux.h, s/irix6-5.h:
+ Move PTY_OPEN to configure.
+
* s/aix4-2.h, s/bsd-common.h, s/cygwin.h, s/darwin.h:
* s/gnu-linux.h, s/hpux10-20.h, s/irix6-5.h, s/template.h:
* s/usg5-4-common.h: Move FIRST_PTY_LETTER, PTY_ITERATION to configure.
#define PTY_NAME_SPRINTF /* none */
#define PTY_TTY_NAME_SPRINTF /* none */
-#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)
/* Used in various places to enable cygwin-specific code changes. */
#define CYGWIN 1
#define PTY_NAME_SPRINTF /* none */
#define PTY_TTY_NAME_SPRINTF /* none */
-/* Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8.
- But we don't have to block SIGCHLD because it is blocked in the
- implementation of grantpt. */
-#define PTY_OPEN \
- do \
- { \
- int slave; \
- if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) \
- fd = -1; \
- else \
- emacs_close (slave); \
- } \
- while (0)
/* PTYs only work correctly on Darwin 7 or higher. So make the default
for process-connection-type dependent on the kernel version. */
#ifdef HAVE_GETPT
#define PTY_NAME_SPRINTF
-#define PTY_OPEN fd = getpt ()
#else /* not HAVE_GETPT */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
#endif /* not HAVE_GETPT */
#ifdef emacs
char *_getpty();
#endif
-/* Here is how to do it. */
-#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); \
-}
/* Ulimit(UL_GMEMLIM) is busted... */
#define ULIMIT_BREAK_VALUE 0x14000000