From xemacs-m  Fri Mar 21 00:04:44 1997
Received: from GS213.SP.CS.CMU.EDU (GS213.SP.CS.CMU.EDU [128.2.209.183])
	by xemacs.org (8.8.5/8.8.5) with SMTP id AAA29923
	for <xemacs-beta@xemacs.org>; Fri, 21 Mar 1997 00:04:44 -0600 (CST)
Received: by GS213.SP.CS.CMU.EDU (AIX 3.2/UCB 5.64/4.03)
          id AA49656; Fri, 21 Mar 1997 01:04:43 -0500
Date: Fri, 21 Mar 1997 01:04:43 -0500
Message-Id: <9703210604.AA49656@GS213.SP.CS.CMU.EDU>
From: Darrell Kindred <dkindred@cmu.edu>
To: xemacs-beta@xemacs.org
Subject: sys/socket.h included twice [patch]
Organization: Carnegie Mellon University School of Computer Science

In lib-src/emacsserver.c, the following code appears:

    #include <sys/types.h>
    #include <sys/file.h>
    #include <sys/socket.h>
    #include <sys/signal.h>
    #include <sys/stat.h> /* Needed for chmod, at least on Linux */
    #include <sys/un.h>
    #include <stdio.h>
    #include <errno.h>
    #include "../src/sysproc.h" /* Needed for select */

In most cases, this causes sys/socket.h to be included
twice, because it is included by sysproc.h if HAVE_SOCKETS
is defined and NO_SUBPROCESSES is not.  Believe it or not,
there are OSes out there that will choke if this happens
(Ultrix 4.3), and this seems to be the only place in the
XEmacs sources where it does happen.

I suspect the first sys/socket.h could be omitted entirely, 
but just in case someone wants to use emacsserver with 
sockets but has NO_SUBPROCESSES defined, we could use the
patch below.

- Darrell

*** lib-src/emacsserver.c.orig	Tue Dec 17 22:29:16 1996
--- lib-src/emacsserver.c	Fri Mar 21 00:39:43 1997
***************
*** 61,73 ****
  
  #include <sys/types.h>
  #include <sys/file.h>
- #include <sys/socket.h>
  #include <sys/signal.h>
  #include <sys/stat.h> /* Needed for chmod, at least on Linux */
  #include <sys/un.h>
  #include <stdio.h>
  #include <errno.h>
  #include "../src/sysproc.h" /* Needed for select */
  
  void
  main ()
--- 61,78 ----
  
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/signal.h>
  #include <sys/stat.h> /* Needed for chmod, at least on Linux */
  #include <sys/un.h>
  #include <stdio.h>
  #include <errno.h>
  #include "../src/sysproc.h" /* Needed for select */
+ #ifndef SOCK_STREAM
+ /* this is normally included by src/sysproc.h.  might be safe to omit
+  * it entirely.  lousy ultrix's sys/socket.h chokes if it's included
+  * twice, so we can't include unconditionally.  */
+ #include <sys/socket.h>
+ #endif
  
  void
  main ()

