comparison src/s/gnu.h @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents a4f53d9b3154
children
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
48 /* Some losing code fails to include this and then assumes 48 /* Some losing code fails to include this and then assumes
49 that because it is braindead that O_RDONLY==0. */ 49 that because it is braindead that O_RDONLY==0. */
50 #ifndef NOT_C_CODE 50 #ifndef NOT_C_CODE
51 #include <fcntl.h> 51 #include <fcntl.h>
52 #endif 52 #endif
53
54 #if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) && defined(HAVE_PTSNAME)
55 /* UNIX98 PTYs are available.
56 Added by Florian Weimer <Florian.Weimer@RUS.Uni-Stuttgart.DE>,
57 RUS-CERT, University of Stuttgart. Based on Emacs code for DGUX. */
58
59 #define PTY_ITERATION for (i = 0; i < 1; i++)
60 /* no iteration at all */
61
62 /* Use getpt() if it's available, because it provides Unix98 PTY
63 emulation for kernels which doesn't support it natively. */
64
65 #ifdef HAVE_GETPT
66 #define PTY_OPEN \
67 do { \
68 fd = getpt(); \
69 if (fcntl (fd, F_SETFL, O_NDELAY) == -1) \
70 fatal ("could not set master PTY to non-block mode"); \
71 } while (0)
72
73 #else
74 /* the master PTY device */
75 #define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
76 #endif
77
78 /* This sets the name of the slave side of the PTY. grantpt(3) and
79 unlockpt(3) may fork a subprocess, so keep sigchld_handler() from
80 intercepting that death. */
81
82 #define PTY_TTY_NAME_SPRINTF \
83 { \
84 char *ptsname(), *ptyname; \
85 \
86 EMACS_BLOCK_SIGNAL (SIGCHLD); \
87 if (grantpt(fd) == -1) \
88 fatal("could not grant slave pty"); \
89 if (unlockpt(fd) == -1) \
90 fatal("could not unlock slave pty"); \
91 if (!(ptyname = ptsname(fd))) \
92 fatal ("could not enable slave pty"); \
93 strncpy(pty_name, ptyname, sizeof(pty_name)); \
94 pty_name[sizeof(pty_name) - 1] = 0; \
95 EMACS_UNBLOCK_SIGNAL (SIGCHLD); \
96 }
97
98 #endif