Compiling on Linux/i686 I get these warnings:
In file included from /usr/src/cvs/release-21-2/src/callproc.c:31:
/usr/src/cvs/release-21-2/src/process.h:143: warning: `PTY_ITERATION' redefined
s/linux.h:216: warning: this is the location of the previous definition
/usr/src/cvs/release-21-2/src/process.h:146: warning: `PTY_OPEN' redefined
s/linux.h:228: warning: this is the location of the previous definition
/usr/src/cvs/release-21-2/src/process.h:148: warning: `PTY_TTY_NAME_SPRINTF'
redefined
s/linux.h:253: warning: this is the location of the previous definition
process.h has:
#ifdef HAVE_GETPT
#define PTY_ITERATION
#define PTY_OPEN \
if ((fd = getpt()) < 0 || grantpt (fd) < 0 || unlockpt (fd) < 0) \
return -1;
#define PTY_NAME_SPRINTF
#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ptsname (fd));
#endif
Compare this with linux.h:
#define PTY_ITERATION for (i = 0; i < 1; i++)
/* no iteration at all */
#define PTY_OPEN \
do { \
fd = getpt(); \
if (fcntl (fd, F_SETFL, O_NDELAY) == -1) \
fatal ("could not set master PTY to non-block mode"); \
} while (0)
#define PTY_TTY_NAME_SPRINTF \
{ \
char *ptsname(), *ptyname; \
\
EMACS_BLOCK_SIGNAL (SIGCHLD); \
if (grantpt(fd) == -1) \
fatal("could not grant slave pty"); \
if (unlockpt(fd) == -1) \
fatal("could not unlock slave pty"); \
if (!(ptyname = ptsname(fd))) \
fatal ("could not enable slave pty"); \
strncpy(pty_name, ptyname, sizeof(pty_name)); \
pty_name[sizeof(pty_name) - 1] = 0; \
EMACS_UNBLOCK_SIGNAL (SIGCHLD); \
}
IMO we should unify this. Could some folks please try the appended
patch? It works for me on Linux 2.4.0.../glibc 2.1.3/i686 but I'd
like to give it some more testing before it gets applied.
Andreas
2000-09-20 Andreas Jaeger <aj(a)suse.de>
* src/s/linux.h: Move PTY handling to process.h
* src/process.h: Unify PTY handling with version from s/linux.h.
Index: src/process.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/process.h,v
retrieving revision 1.8.2.10
diff -u -r1.8.2.10 process.h
--- src/process.h 2000/06/12 04:18:21 1.8.2.10
+++ src/process.h 2000/09/20 08:00:01
@@ -139,13 +139,43 @@
#endif /* emacs */
-#ifdef HAVE_GETPT
+#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) &&
defined(HAVE_PTSNAME)
+/* No iteration at all: */
#define PTY_ITERATION
-#define PTY_OPEN \
- if ((fd = getpt()) < 0 || grantpt (fd) < 0 || unlockpt (fd) < 0) \
- return -1;
+
+#ifdef HAVE_GETPT
+/* Use getpt() if it's available. */
+
+#define PTY_OPEN \
+ do { \
+ fd = getpt(); \
+ if (fcntl (fd, F_SETFL, O_NDELAY) == -1) \
+ fatal ("could not set master PTY to non-block mode"); \
+ } while (0)
+
#define PTY_NAME_SPRINTF
-#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ptsname (fd));
+
+#else
+/* the master PTY device */
+#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
+#endif
+
+#define PTY_TTY_NAME_SPRINTF \
+ { \
+ char *ptsname(), *ptyname; \
+ \
+ EMACS_BLOCK_SIGNAL (SIGCHLD); \
+ if (grantpt(fd) == -1) \
+ fatal("could not grant slave pty"); \
+ if (unlockpt(fd) == -1) \
+ fatal("could not unlock slave pty"); \
+ if (!(ptyname = ptsname(fd))) \
+ fatal ("could not enable slave pty"); \
+ strncpy(pty_name, ptyname, sizeof(pty_name)); \
+ pty_name[sizeof(pty_name) - 1] = 0; \
+ EMACS_UNBLOCK_SIGNAL (SIGCHLD); \
+ }
+
#endif
#endif /* INCLUDED_process_h_ */
Index: src/s/linux.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/s/linux.h,v
retrieving revision 1.11.2.4
diff -u -r1.11.2.4 linux.h
--- src/s/linux.h 2000/09/14 06:31:09 1.11.2.4
+++ src/s/linux.h 2000/09/20 08:00:01
@@ -208,48 +208,3 @@
/* XEmacs: removed setpgrp() definition because we use setpgid() when
it's available, and autodetect it. */
-#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) &&
defined(HAVE_PTSNAME)
-/* UNIX98 PTYs are available.
- Added by Florian Weimer <Florian.Weimer(a)RUS.Uni-Stuttgart.DE>,
- RUS-CERT, University of Stuttgart. Based on Emacs code for DGUX. */
-
-#define PTY_ITERATION for (i = 0; i < 1; i++)
-/* no iteration at all */
-
-/* Use getpt() if it's available, because it provides Unix98 PTY
- emulation for kernels which doesn't support it natively. */
-
-#ifdef HAVE_GETPT
-#define PTY_OPEN \
- do { \
- fd = getpt(); \
- if (fcntl (fd, F_SETFL, O_NDELAY) == -1) \
- fatal ("could not set master PTY to non-block mode"); \
- } while (0)
-
-#else
-/* the master PTY device */
-#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
-#endif
-
-/* This sets the name of the slave side of the PTY. grantpt(3) and
- unlockpt(3) may fork a subprocess, so keep sigchld_handler() from
- intercepting that death. */
-
-#define PTY_TTY_NAME_SPRINTF \
- { \
- char *ptsname(), *ptyname; \
- \
- EMACS_BLOCK_SIGNAL (SIGCHLD); \
- if (grantpt(fd) == -1) \
- fatal("could not grant slave pty"); \
- if (unlockpt(fd) == -1) \
- fatal("could not unlock slave pty"); \
- if (!(ptyname = ptsname(fd))) \
- fatal ("could not enable slave pty"); \
- strncpy(pty_name, ptyname, sizeof(pty_name)); \
- pty_name[sizeof(pty_name) - 1] = 0; \
- EMACS_UNBLOCK_SIGNAL (SIGCHLD); \
- }
-
-#endif
--
Andreas Jaeger
SuSE Labs aj(a)suse.de
private aj(a)arthur.inka.de
http://www.suse.de/~aj