🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99203

Re: control-C problem on HP9000/300 series

#99203
From: Piet van Oostrum
Date: Thu, 18 Oct 1990 17:05
368 lines
10708 bytes
>>>>> In article <250@ripple.cs.utexas.edu>, pkn@CS.UTEXAS.EDU (Kay Nettle)
>>>>> (KN) writes:

KN> This happens under version 18.55.  I start up a shell, execute a
KN> command that I want to interrupt, so I do a C-C,C-C, it's echoed in
KN> the mini buffer, but it has no effect.  Does anyone have a fix to this
KN> problem. 

Here is the complete set of patches for HP/UX that I have applied to emacs.
(I have posted these before, and some parts of it come from others). These
solve a number of problems:

1. Signals to child provcesses work now (like the C-c C-c mentioned above)

2. When running under X11, C-g now correctly interrupts long-running commands

3. When running under X11, the window is redispainted even if emacs is doing
some work (e.g. if your window becomes visible after being behind another
one.

4. A nasty bug in alloca is solved. This bug is very infrequent unless you
apply the other patches.

% cdiff alloca.s$X
*** alloca.s.~1~	Fri Sep 15 16:35:39 1989
--- alloca.s	Tue May  1 17:18:08 1990
***************
*** 92,103 ****
  	sub.l	&MAXREG*4,%d1	# space for saving registers
  	mov.l	%d1,%sp		# save new value of sp
  	tst.b	PROBE(%sp)	# create pages (sigh)
  	move.w	&MAXREG-1,%d0
  copy_regs_loop:			/* save caller's saved registers */
! 	mov.l	(%a1)+,(%sp)+
  	dbra	%d0,copy_regs_loop
! 	mov.l	%sp,%d0		# return value
! 	mov.l	%d1,%sp
  	add.l	&-4,%sp		# adjust tos
  	jmp	(%a0)		# rts
  #endif /* new hp assembler */
--- 92,105 ----
  	sub.l	&MAXREG*4,%d1	# space for saving registers
  	mov.l	%d1,%sp		# save new value of sp
  	tst.b	PROBE(%sp)	# create pages (sigh)
+ 	mov.l	%a2,%d1		# save reg a2
+ 	mov.l	%sp,%a2
  	move.w	&MAXREG-1,%d0
  copy_regs_loop:			/* save caller's saved registers */
! 	mov.l	(%a1)+,(%a2)+
  	dbra	%d0,copy_regs_loop
! 	mov.l	%a2,%d0		# return value
! 	mov.l	%d1,%a2		# restore a2
  	add.l	&-4,%sp		# adjust tos
  	jmp	(%a0)		# rts
  #endif /* new hp assembler */
% cdiff keyboard.c$X
*** keyboard.c.~1~	Wed Apr  4 14:53:49 1990
--- keyboard.c	Thu Apr 26 14:46:27 1990
***************
*** 719,724 ****
--- 719,773 ----
    errno = old_errno;
  }
  
+ #ifdef HPUX
+ /* tells if an alarm is outstanding for emptying the socket */
+ int socket_alarm;
+ 
+ static void
+ empty_socket_interrupt()
+ {
+   int nread;
+   char buf[256 * BUFFER_SIZE_FACTOR];
+   register int i;
+   int old_errno = errno;
+ 
+   if (waiting_for_input) return;
+ 
+   fcntl (fileno (stdin), F_SETFL, O_NDELAY);
+ 
+   /* Read what is waiting.  */
+ 
+     nread = (*read_socket_hook) (0, buf, sizeof buf);
+ 
+ #ifdef EBADSLT
+   if (nread == -1 && (errno == EAGAIN || errno == EBADSLT))
+ #else
+   if (nread == -1 && errno == EAGAIN)
+ #endif
+     nread = 0;
+ 
+   fcntl (fileno (stdin), F_SETFL, 0);
+ 
+   /* Scan the chars for C-g and store them in kbd_buffer.  */
+   kbd_ptr = kbd_buffer;
+   for (i = 0; i < nread; i++)
+     {
+       kbd_buffer_store_char (buf[i]);
+       /* Don't look at input that follows a C-g too closely.
+ 	 This reduces lossage due to autorepeat on C-g.  */
+       if (buf[i] == Ctl ('G'))
+ 	break;
+     }
+ 
+   /* reestablish interrupt */
+   signal (SIGALRM, empty_socket_interrupt);
+   alarm (1);
+ 
+   errno = old_errno;
+ }
+ 
+ #endif /* HPUX */
+ 
  /* read a character from the keyboard; call the redisplay if needed */
  /* commandflag 0 means do not do auto-saving, but do do redisplay.
     -1 means do not do redisplay, but do do autosaving.
***************
*** 733,738 ****
--- 782,794 ----
    Lisp_Object tem;
    extern request_echo ();
  
+ #ifdef HPUX
+   if (socket_alarm) {
+       alarm (0);
+       socket_alarm = 0;
+   }      
+ #endif
+ 
    if ((c = unread_command_char) >= 0)
      {
        unread_command_char = -1;
***************
*** 869,874 ****
--- 925,938 ----
  	}
      }
  
+ #ifdef HPUX
+   if (read_socket_hook) {
+       socket_alarm = 1;
+       signal (SIGALRM, empty_socket_interrupt);
+       alarm (1);
+   }      
+ #endif
+ 
    return c;
  }
  
***************
*** 1094,1119 ****
  
  #else /* no FIONREAD */
  #ifdef USG
    if (kbd_count)
      abort ();
  
    fcntl (fileno (stdin), F_SETFL, O_NDELAY);
!   kbd_ptr = kbd_buffer;
    if (read_socket_hook)
!     {
!       kbd_count = (*read_socket_hook) (0, kbd_buffer, sizeof kbd_buffer);
!     }
    else
!     {
!       kbd_count = read (fileno (stdin), kbd_buffer, sizeof kbd_buffer);
!     }
  #ifdef EBADSLT
!   if (kbd_count == -1 && (errno == EAGAIN || errno == EBADSLT))
  #else
!   if (kbd_count == -1 && errno == EAGAIN)
  #endif
!     kbd_count = 0;
    fcntl (fileno (stdin), F_SETFL, 0);
  #else /* not USG */
    you lose
  #endif /* not USG */
--- 1158,1209 ----
  
  #else /* no FIONREAD */
  #ifdef USG
+   char buf[256 * BUFFER_SIZE_FACTOR];
+   register int i;
+ #ifdef HPUX
+   int mask;
+ #endif
+ 
    if (kbd_count)
      abort ();
  
+ #ifdef HPUX
+   if (socket_alarm)
+       mask = sigblock (sigmask (SIGALRM));
+ #endif
+ 
    fcntl (fileno (stdin), F_SETFL, O_NDELAY);
! 
!   /* Read what is waiting.  */
    if (read_socket_hook)
!     nread = (*read_socket_hook) (0, buf, sizeof buf);
    else
!     nread = read (fileno(stdin), buf, sizeof buf);
  #ifdef EBADSLT
!   if (nread == -1 && (errno == EAGAIN || errno == EBADSLT))
  #else
!   if (nread == -1 && errno == EAGAIN)
  #endif
!     nread = 0;
! 
    fcntl (fileno (stdin), F_SETFL, 0);
+ 
+   /* Scan the chars for C-g and store them in kbd_buffer.  */
+   kbd_ptr = kbd_buffer;
+   for (i = 0; i < nread; i++)
+     {
+       kbd_buffer_store_char (buf[i]);
+       /* Don't look at input that follows a C-g too closely.
+ 	 This reduces lossage due to autorepeat on C-g.  */
+       if (buf[i] == Ctl ('G'))
+ 	break;
+     }
+ 
+ #ifdef HPUX
+   if (socket_alarm)
+       sigsetmask(mask);
+ #endif
+ 
  #else /* not USG */
    you lose
  #endif /* not USG */
% cdiff x11term.h{~,}
*** x11term.h~	Fri Sep 15 15:20:26 1989
--- x11term.h	Thu Apr 26 14:03:25 1990
***************
*** 11,17 ****
--- 11,22 ----
  #define sigmask(no) (1L << ((no) - 1))
  #endif
  
+ #ifdef HPUX
  #define BLOCK_INPUT_DECLARE() int BLOCK_INPUT_mask
+ #define BLOCK_INPUT() BLOCK_INPUT_mask = sigblock (sigmask (SIGALRM))
+ #define UNBLOCK_INPUT() sigsetmask (BLOCK_INPUT_mask)
+ #else /* not HPUX */
+ #define BLOCK_INPUT_DECLARE() int BLOCK_INPUT_mask
  #ifdef SIGIO
  #define BLOCK_INPUT() BLOCK_INPUT_mask = sigblock (sigmask (SIGIO))
  #define UNBLOCK_INPUT() sigsetmask (BLOCK_INPUT_mask)
***************
*** 19,23 ****
--- 24,29 ----
  #define BLOCK_INPUT()
  #define UNBLOCK_INPUT()
  #endif /* SIGIO */
+ #endif /* HPUX */
  
  #define CLASS  "emacs"	/* class id for GNU Emacs, used in .Xdefaults, etc. */
% cdiff process.c{.orig,}
*** process.c.orig	Fri Sep 15 16:28:36 1989
--- process.c	Fri Apr 20 13:17:06 1990
***************
*** 1057,1062 ****
--- 1057,1079 ----
  	  signal (SIGHUP, SIG_DFL);
  #endif
  #endif /* HAVE_PTYS */
+ 
+ 	/* Give child clean slate for signals */
+ #ifdef SIGCHLD
+ #ifdef BSD4_1
+ 	sigrelse (SIGCHLD);
+ #else /* not BSD4_1 */
+ #ifdef HPUX
+ 	sigsetmask (0);
+ #endif /* HPUX */
+ #if defined (BSD) || defined (UNIPLUS)
+ 	sigsetmask (0);
+ #else /* ordinary USG */
+ 	signal (SIGCHLD, sigchld);
+ #endif /* ordinary USG */
+ #endif /* not BSD4_1 */
+ #endif /* SIGCHLD */
+ 
  	child_setup_tty (xforkout);
  	child_setup (xforkin, xforkout, xforkout, new_argv, env);
        }
***************
*** 1413,1427 ****
        if (read_kbd && kbd_count)
  	nfds = 0;
        else
! #ifdef IBMRTAIX
  	nfds = select (MAXDESC, &Available, 0, 0, &timeout);
  #else
- #ifdef HPUX
- 	nfds = select (MAXDESC, &Available, 0, 0, &timeout);
- #else
  	nfds = select (MAXDESC, &Available, 0, &Exception, &timeout);
  #endif
- #endif
        xerrno = errno;
  
        if (fix_screen_hook)
--- 1430,1440 ----
        if (read_kbd && kbd_count)
  	nfds = 0;
        else
! #if defined (IBMRTAIX) || defined (HPUX)
  	nfds = select (MAXDESC, &Available, 0, 0, &timeout);
  #else
  	nfds = select (MAXDESC, &Available, 0, &Exception, &timeout);
  #endif
        xerrno = errno;
  
        if (fix_screen_hook)
***************
*** 1771,1776 ****
--- 1784,1790 ----
      error ("Process %s is not active",
  	   XSTRING (p->name)->data);
  
+ #ifndef HPUX
  #ifdef TIOCGPGRP		/* Not sure about this! (fnf) */
    /* If we are using pgrps, get a pgrp number and make it negative.  */
    if (!NULL (current_group))
***************
*** 1785,1790 ****
--- 1799,1805 ----
       the child itself heads the pgrp.  */
    gid = - XFASTINT (p->pid);
  #endif /* not using pgrps */
+ #endif /* not HPUX */
  
    switch (signo)
      {
***************
*** 1800,1805 ****
--- 1815,1827 ----
        flush_pending_output (XFASTINT (p->infd));
        break;
      }
+ 
+ #ifdef HPUX
+   if (!NULL (current_group))
+     ioctl (XFASTINT (p->infd), TIOCSIGSEND, signo);
+   else
+     kill (XFASTINT (p->pid), signo);
+ #else /* not HPUX */
    /* gid may be a pid, or minus a pgrp's number */
  #ifdef BSD
    /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
***************
*** 1808,1813 ****
--- 1830,1836 ----
  #else /* Not BSD.  */
    kill (gid, signo);
  #endif /* Not BSD.  */
+ #endif /* Not HPUX  */
  
    /* Put notices in buffers now, since it is safe now.
       Because of this, we know that a process we have just killed
% 
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31 30 531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31 30 513791   Internet:  piet@cs.ruu.nl   (*`Pete')
Technical Details
Message-ID: <4074@ruuinf.cs.ruu.nl>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!cs.ruu.nl!piet
References: <250@ripple.cs.utexas.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,44d892d287a1d9d7
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-18 10:05:02 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!cs.ruu.nl!piet
From: piet@cs.ruu.nl (Piet van Oostrum)
Newsgroups: gnu.emacs.bug
Subject: Re: control-C problem on HP9000/300 series
Keywords: shell
Message-ID: <4074@ruuinf.cs.ruu.nl>
Date: 18 Oct 90 17:05:02 GMT
References: <250@ripple.cs.utexas.edu>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: piet@cs.ruu.nl (Piet van Oostrum)
Distribution: gnu
Organization: Dept of Computer Science, Utrecht University, The Netherlands
Lines: 368
Approved: bug-gnu-emacs@prep.ai.mit.edu
Posted: Thu Oct 18 18:05:02 1990