🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98921

Interrupt input works on HP-UX 7.0

#98921
From: Tor Lillqvist
Date: Tue, 12 Feb 1991 17:19
413 lines
11230 bytes
In GNU Emacs 18.57.8 of Tue Feb 12 1991 on hemuli (hpux)

I now have interrupt input working on HP-UX 7.0 (both series 300 and
800) with the changes below.  I also moved stuff common to both
architectures out from m-hp9000s{3,8}00.h into s-hpux.h, and created
the new file s-hpux-7.h, also included below.

I have to link with -lBSD to get interrupt input working.  Without
-lBSD, it worked until you typed control-G and
quit_throw_to_read_command_char was called.  After that it got into a
loop where the select in wait_reading_process_input claimed that there
was input, but detect_input_pending didn't find any.

I also removed the strange server ping code from xfixscreen -- it
caused an otherwise idle Emacs to chew up CPU by getting SIGIOs
repeatedly.  I guess this was caused by the "static" in xfixscreen.
"static" has been #defined as empty in s-hpux.h, so the
server_ping_timer variable didn't keep it's value.

Now the only problem is that after running terminal-emulator,
control-g doesn't work any more...

s-hpux-7.h:
================
#define HPUX_7

/* Define this so that we won't use USG the style setpgrp() without
   args, because we link with -lBSD which has a BSD style setpgrp().  */
#define HAVE_SETSID

/* Interrupt input works fine on HP-UX 7.0.  */
#define INTERRUPT_INPUT

#include "s-hpux.h"
================
diff -c2 ../src/callproc.c ./callproc.c
*** ../src/callproc.c	Sat Jan  5 02:13:47 1991
--- ./callproc.c	Tue Feb 12 15:03:30 1991
***************
*** 199,203 ****
--- 199,207 ----
  #ifdef USG
  #ifdef HAVE_PTYS
+ #ifdef HAVE_SETSID
+ 	setsid ();
+ #else
  	setpgrp ();
+ #endif
  #endif
  #endif
diff -c2 ../src/m-hp9000s300.h ./m-hp9000s300.h
*** ../src/m-hp9000s300.h	Tue Jan  8 19:54:11 1991
--- ./m-hp9000s300.h	Tue Feb 12 15:15:51 1991
***************
*** 138,145 ****
  #endif
  
! /* The symbol FIONREAD is defined, but the feature does not work
!    on the 200/300.  */
  
  #define BROKEN_FIONREAD
  
  /* In older versions of hpux, for unknown reasons, S_IFLNK is defined
--- 138,147 ----
  #endif
  
! /* The symbol FIONREAD is defined, but the feature is said not to work
!    on the 200/300 before HP-UX 7.0.  */
  
+ #ifndef HPUX_7
  #define BROKEN_FIONREAD
+ #endif
  
  /* In older versions of hpux, for unknown reasons, S_IFLNK is defined
***************
*** 156,178 ****
  #endif
  
- /* Define the BSTRING functions in terms of the sysV functions.
-    Version 6 of HP-UX supplies these in the BSD library,
-    but that library has reported bugs in `signal'.  */
- 
- /* #ifdef HPUX_5 */
- #define bcopy(a,b,s)	memcpy (b,a,s)
- #define bzero(a,s)	memset (a,0,s)
- #define bcmp		memcmp
- /* #endif */
- 
- /* On USG systems these have different names.
-    Version 6 of HP-UX supplies these in the BSD library,
-    which we currently want to avoid using.  */
- 
- /* #ifdef HPUX_5 */
- #define index strchr
- #define rindex strrchr
- /* #endif */
- 
  /* Define C_SWITCH_MACHINE to be +X if you want the s200/300
   * Emacs to run on both 68010 and 68020 based hp-ux's.
--- 158,161 ----
***************
*** 192,201 ****
  #define C_SWITCH_MACHINE -Wc,-Nd4000,-Ns3000
  #endif
- #endif
- 
- /* Define NEED_BSDTTY if you have such. */
- 
- #ifndef NOMULTIPLEJOBS
- #define NEED_BSDTTY
  #endif
  
--- 175,178 ----
diff -c2 ../src/m-hp9000s800.h ./m-hp9000s800.h
*** ../src/m-hp9000s800.h	Tue Jan  8 19:54:14 1991
--- ./m-hp9000s800.h	Tue Feb 12 15:17:51 1991
***************
*** 129,136 ****
  #define LIBS_MACHINE
  #define LIBS_DEBUG
- 
- /* Define NEED_BSDTTY if you have such. */
- 
- #define NEED_BSDTTY
  
  /* The standard definitions of these macros would work ok,
--- 129,132 ----
***************
*** 163,187 ****
  #define CPTIME_SYMBOL "cp_time"
  #define DKXFER_SYMBOL "dk_xfer"
- 
- /* In hpux, for unknown reasons, S_IFLNK is defined even though
-    symbolic links do not exist.
-    Make sure our conditionals based on S_IFLNK are not confused.
- 
-    Here we assume that stat.h is included before config.h
-    so that we can override it here.  */
- 
- #undef S_IFLNK
- 
- /* Define the BSTRING functions in terms of the sysV functions. */
- 
- #define bcopy(a,b,s)	memcpy (b,a,s)
- #define bzero(a,s)	memset (a,0,s)
- #define bcmp		memcmp
- 
- /* On USG systems these have different names. */
- 
- #define index strchr
- #define rindex strrchr
- 
- /* Include the file bsdtty.h, since job control exists.  */
- #define NEED_BSDTTY
--- 159,160 ----
diff -c2 ../src/s-hpux.h ./s-hpux.h
*** ../src/s-hpux.h	Tue Jan  8 20:03:14 1991
--- ./s-hpux.h	Tue Feb 12 15:15:49 1991
***************
*** 94,101 ****
  /* #define NONSYSTEM_DIR_LIBRARY */
  
! /* Define this symbol if your system has the functions bcopy, etc.
!  * s800 and later versions of s300 (s200) kernels have equivilents
!  * of the BSTRING functions of BSD.  If your s200 kernel doesn't have
!  * em comment out this section.
   */
  
--- 94,100 ----
  /* #define NONSYSTEM_DIR_LIBRARY */
  
! /*
!  *	Define this symbol if your system has the functions bcopy, etc.
!  *	HP-UX has them in -lBSD, but it is more winning to use #defines.
   */
  
***************
*** 102,105 ****
--- 101,116 ----
  #define BSTRING
  
+ #ifdef HPUX_7
+ #define bcopy(s,d,n) memmove(d,s,n)
+ #else
+ #define bcopy(s,d,n) memcpy(d,s,n)
+ #endif
+ 
+ #define bzero(d,n) memset(d,0,n)
+ #define bcmp(a,b,n) memcmp(a,b,n)
+ 
+ #define index strchr
+ #define rindex strrchr
+ 
  /* subprocesses should be defined if you want to
   have code for asynchronous subprocesses
***************
*** 195,200 ****
  #define srand srand48
  
! /* In hpux, the symbol SIGIO is defined, but the feature
!    does not really exist.
  
     Here we assume that signal.h is included before config.h
--- 206,211 ----
  #define srand srand48
  
! /* In pre-7.0 HP-UX, the symbol SIGIO is defined, but the feature
!    is said to not really exist.
  
     Here we assume that signal.h is included before config.h
***************
*** 201,205 ****
--- 212,218 ----
     so that we can override it here.  */
  
+ #ifndef HPUX_7
  #undef SIGIO
+ #endif
  
  /* USG systems tend to put everything declared static
***************
*** 216,221 ****
--- 229,239 ----
  #define LIBS_SYSTEM -ln
  #else
+ #ifdef HPUX_7
+ /* We want the BSD version of signal for interrupt input to work.  */
+ #define LIBS_SYSTEM -lBSD
+ #else
  #define LIBS_SYSTEM
  #endif
+ #endif
  
  /* Some additional system facilities exist.  */
***************
*** 245,250 ****
--- 263,270 ----
    1800, 2400, 3600, 4800, 7200, 9600, 19200, 38400 }
  
+ #ifndef HPUX_7
  /* This is needed for HPUX version 6.2; it may not be needed for 6.2.1.  */
  #define SHORT_CAST_BUG
+ #endif
  
  /* Define killpg so that we have process group functionality under HP.  */
***************
*** 257,259 ****
--- 277,285 ----
  #endif
  #define WRETCODE(w) (((w) >> 8) & 0377)
+ #endif
+ 
+ /* Define NEED_BSDTTY if you have such. */
+ 
+ #ifndef NOMULTIPLEJOBS
+ #define NEED_BSDTTY
  #endif
diff -c2 ../src/sysdep.c ./sysdep.c
*** ../src/sysdep.c	Wed Jan 16 04:43:59 1991
--- ./sysdep.c	Tue Feb 12 15:09:47 1991
***************
*** 749,752 ****
--- 749,777 ----
  
  #else /* not FASYNC, not STRIDE */
+ #ifdef HPUX_7
+ 
+ request_sigio ()
+ {
+   int on = 1;
+   
+   if (read_socket_hook)
+     ioctl (0, FIOASYNC, &on);
+   else
+     ioctl (0, FIOSSAIOSTAT, &on);
+   interrupts_deferred = 0;
+ }
+ 
+ unrequest_sigio ()
+ {
+   int off = 0;
+ 
+   if (read_socket_hook)
+     ioctl (0, FIOASYNC, &off);
+   else
+     ioctl (0, FIOSSAIOSTAT, &off);
+   interrupts_deferred = 1;
+ }
+ 
+ #else
   
  request_sigio ()
***************
*** 760,763 ****
--- 785,789 ----
  }
   
+ #endif /* HPUX_7 */
  #endif /* STRIDE */
  #endif /* FASYNC */
***************
*** 768,771 ****
--- 794,800 ----
  int term_initted;		/* 1 if outer tty status has been recorded */
  
+ #ifdef HPUX_7
+ int old_io_owner;
+ #endif
  #ifdef F_SETOWN
  int old_fcntl_owner;
***************
*** 959,962 ****
--- 988,1000 ----
  #endif
  
+ #ifdef HPUX
+       if (interrupt_input)
+ 	{
+ 	  int pid = getpid ();
+ 	  ioctl (0, FIOGSAIOOWN, &old_io_owner);
+ 	  ioctl (0, FIOSSAIOOWN, &pid);
+ 	  init_sigio ();
+ 	}
+ #else
  #ifdef F_SETFL
  #ifdef F_GETOWN		/* F_SETFL does not imply existance of F_GETOWN */
***************
*** 969,972 ****
--- 1007,1011 ----
  #endif /* F_GETOWN */
  #endif /* F_SETFL */
+ #endif /* !HPUX_7 */
  
        /* If going to use CBREAK mode, we must request C-g to interrupt
diff -c2 ../src/x11term.c ./x11term.c
*** ../src/x11term.c	Thu Jan 24 19:36:53 1991
--- ./x11term.c	Tue Feb 12 18:50:08 1991
***************
*** 1495,1522 ****
  xfixscreen ()
  {
! 	static int server_ping_timer;
! 	BLOCK_INPUT_DECLARE ();
  
! 	if (server_ping_timer > 0)
! 	  server_ping_timer--;
! 	else
! 	  {
! 	    server_ping_timer = 100;
! 
! 	    /* Yes, this is really what I mean -- Check to see if we've
! 	     * lost our connection */
! 
! 	    BLOCK_INPUT ();
! 	    XSetErrorHandler(0);
! 	    XSetIOErrorHandler(0);
! 	    XNoOp (XXdisplay);
! 	    XFlush (XXdisplay);
! 	    XSetErrorHandler(handler);
! 	    XSetIOErrorHandler(handler);
! 	    if (!InUpdate && !CursorExists)
! 		    CursorToggle ();
! 
! 	    UNBLOCK_INPUT ();
! 	  }
  }
  	
--- 1495,1505 ----
  xfixscreen ()
  {
!   BLOCK_INPUT_DECLARE ();
  
!   if (!InUpdate && !CursorExists) {
!     BLOCK_INPUT ();
!     CursorToggle ();
!     UNBLOCK_INPUT ();
!   }
  }
  	
***************
*** 2007,2012 ****
  						 * check the def of the macro;
  						 * it is a genuine lvalue */
! 	setpgrp (0,getpid());
  	
  #ifdef F_SETOWN
  	old_fcntl_owner = fcntl (0, F_GETOWN, 0);
--- 1990,2006 ----
  						 * check the def of the macro;
  						 * it is a genuine lvalue */
! #ifdef HAVE_SETSID
! 	setsid ();
! #else
! 	setpgrp (0,getpid());	/* On USG, args are ignored */
! #endif
  	
+ #ifdef HPUX_7
+ 	{
+ 	  int neg_pid = - getpid ();
+ 	  ioctl (0, SIOCSPGRP, &neg_pid);
+ 	  request_sigio ();
+ 	}
+ #else
  #ifdef F_SETOWN
  	old_fcntl_owner = fcntl (0, F_GETOWN, 0);
***************
*** 2017,2020 ****
--- 2011,2015 ----
  #endif /* F_SETOWN_SOCK_NEG */
  #endif /* F_SETOWN */
+ #endif /* HPUX_7 */
  
  	/* Enable interrupt_input because otherwise we cannot asynchronously
Technical Details
Message-ID: <9102121719.AA21646@tik.vtt.fi>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,a6745163508bb19e,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-02-12 09:19:33 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage
From: tml@TIK.VTT.FI (Tor Lillqvist)
Newsgroups: gnu.emacs.bug
Subject: Interrupt input works on HP-UX 7.0
Message-ID: <9102121719.AA21646@tik.vtt.fi>
Date: 12 Feb 91 17:19:33 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 413
Approved: bug-gnu-emacs@prep.ai.mit.edu