Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Aug 1999 11:37:38 +0200
From:      Martin Cracauer <cracauer@cons.org>
To:        Thomas David Rivers <rivers@dignus.com>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/12877: interactive /bin/sh ignores ^C and ^Z in while loops
Message-ID:  <19990802113738.A79295@cons.org>
In-Reply-To: <199907300200.TAA98004@freefall.freebsd.org>; from Thomas David Rivers on Thu, Jul 29, 1999 at 07:00:03PM -0700
References:  <199907300200.TAA98004@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii

In <199907300200.TAA98004@freefall.freebsd.org>, Thomas David Rivers wrote: 
> The following reply was made to PR bin/12877; it has been noted by GNATS.
> 
> From: Thomas David Rivers <rivers@dignus.com>
> To: freebsd-gnats-submit@FreeBSD.ORG, rdm@cfcl.com
> Cc:  
> Subject: Re: bin/12877: interactive /bin/sh ignores ^C and ^Z in while loops
> Date: Thu, 29 Jul 1999 21:56:46 -0400 (EDT)
> 
>  I believe this is the same as PR bin/9173 - submitted last Dec.

I committed a fix to these problems on 1999/04/03 to -current and
1999/07/25 to -stable. Diff to -stable also appended. Could you please
verify that this fixes your problem so I can close the PR? Thanks.

shells before <= 2.2.7 work because they don't have my fixes for
non-interactive loops in them.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany     http://www.bsdhh.org/

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: eval.c
===================================================================
RCS file: /home/CVS-FreeBSD/src/bin/sh/eval.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -c -r1.17 -r1.18
*** eval.c	1999/04/03 12:55:51	1.17
--- eval.c	1999/04/21 11:52:39	1.18
***************
*** 39,45 ****
  static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
  #endif
  static const char rcsid[] =
! 	"$Id: eval.c,v 1.17 1999/04/03 12:55:51 cracauer Exp $";
  #endif /* not lint */
  
  #include <signal.h>
--- 39,45 ----
  static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
  #endif
  static const char rcsid[] =
! 	"$Id: eval.c,v 1.18 1999/04/21 11:52:39 cracauer Exp $";
  #endif /* not lint */
  
  #include <signal.h>
***************
*** 410,416 ****
  	}
  	if (! backgnd) {
  		INTOFF;
! 		exitstatus = waitforjob(jp);
  		INTON;
  	}
  }
--- 410,416 ----
  	}
  	if (! backgnd) {
  		INTOFF;
! 		exitstatus = waitforjob(jp, (int *)NULL);
  		INTON;
  	}
  }
***************
*** 509,515 ****
  	INTON;
  	if (n->npipe.backgnd == 0) {
  		INTOFF;
! 		exitstatus = waitforjob(jp);
  		TRACE(("evalpipe:  job done exit status %d\n", exitstatus));
  		INTON;
  	}
--- 509,515 ----
  	INTON;
  	if (n->npipe.backgnd == 0) {
  		INTOFF;
! 		exitstatus = waitforjob(jp, (int *)NULL);
  		TRACE(("evalpipe:  job done exit status %d\n", exitstatus));
  		INTON;
  	}
***************
*** 602,607 ****
--- 602,608 ----
  	struct localvar *volatile savelocalvars;
  	volatile int e;
  	char *lastarg;
+ 	int realstatus;
  #if __GNUC__
  	/* Avoid longjmp clobbering */
  	(void) &argv;
***************
*** 861,869 ****
  parent:	/* parent process gets here (if we forked) */
  	if (mode == 0) {	/* argument to fork */
  		INTOFF;
! 		exitstatus = waitforjob(jp);
  		INTON;
! 		if (iflag && loopnest > 0 && WIFSIGNALED(exitstatus)) {
  			evalskip = SKIPBREAK;
  			skipcount = loopnest;
  		}
--- 862,870 ----
  parent:	/* parent process gets here (if we forked) */
  	if (mode == 0) {	/* argument to fork */
  		INTOFF;
! 		exitstatus = waitforjob(jp, &realstatus);
  		INTON;
! 		if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) {
  			evalskip = SKIPBREAK;
  			skipcount = loopnest;
  		}
Index: expand.c
===================================================================
RCS file: /home/CVS-FreeBSD/src/bin/sh/expand.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -c -r1.26 -r1.27
*** expand.c	1999/04/13 04:13:09	1.26
--- expand.c	1999/04/21 11:52:39	1.27
***************
*** 39,45 ****
  static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
  #endif
  static const char rcsid[] =
! 	"$Id: expand.c,v 1.26 1999/04/13 04:13:09 tegge Exp $";
  #endif /* not lint */
  
  #include <sys/types.h>
--- 39,45 ----
  static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
  #endif
  static const char rcsid[] =
! 	"$Id: expand.c,v 1.27 1999/04/21 11:52:39 cracauer Exp $";
  #endif /* not lint */
  
  #include <sys/types.h>
***************
*** 493,499 ****
  	if (in.buf)
  		ckfree(in.buf);
  	if (in.jp)
! 		exitstatus = waitforjob(in.jp);
  	if (quoted == 0)
  		recordregion(startloc, dest - stackblock(), 0);
  	TRACE(("evalbackq: size=%d: \"%.*s\"\n",
--- 493,499 ----
  	if (in.buf)
  		ckfree(in.buf);
  	if (in.jp)
! 		exitstatus = waitforjob(in.jp, (int *)NULL);
  	if (quoted == 0)
  		recordregion(startloc, dest - stackblock(), 0);
  	TRACE(("evalbackq: size=%d: \"%.*s\"\n",
Index: jobs.c
===================================================================
RCS file: /home/CVS-FreeBSD/src/bin/sh/jobs.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -c -r1.23 -r1.24
*** jobs.c	1998/09/08 13:16:52	1.23
--- jobs.c	1999/04/21 11:52:39	1.24
***************
*** 39,45 ****
  static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
  #endif
  static const char rcsid[] =
! 	"$Id: jobs.c,v 1.23 1998/09/08 13:16:52 cracauer Exp $";
  #endif /* not lint */
  
  #include <fcntl.h>
--- 39,45 ----
  static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
  #endif
  static const char rcsid[] =
! 	"$Id: jobs.c,v 1.24 1999/04/21 11:52:39 cracauer Exp $";
  #endif /* not lint */
  
  #include <fcntl.h>
***************
*** 213,219 ****
  #endif
  	restartjob(jp);
  	INTOFF;
! 	status = waitforjob(jp);
  	INTON;
  	return status;
  }
--- 213,219 ----
  #endif
  	restartjob(jp);
  	INTOFF;
! 	status = waitforjob(jp, (int *)NULL);
  	INTON;
  	return status;
  }
***************
*** 702,710 ****
   */
  
  int
! waitforjob(jp)
  	struct job *jp;
! 	{
  #if JOBS
  	int mypgrp = getpgrp();
  #endif
--- 702,711 ----
   */
  
  int
! waitforjob(jp, origstatus)
  	struct job *jp;
! 	int *origstatus;
! {
  #if JOBS
  	int mypgrp = getpgrp();
  #endif
***************
*** 730,735 ****
--- 731,738 ----
  		curjob = jp - jobtab + 1;
  #endif
  	status = jp->ps[jp->nprocs - 1].status;
+ 	if (origstatus != NULL)
+ 		*origstatus = status;
  	/* convert to 8 bits */
  	if (WIFEXITED(status))
  		st = WEXITSTATUS(status);
Index: jobs.h
===================================================================
RCS file: /home/CVS-FreeBSD/src/bin/sh/jobs.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -c -r1.10 -r1.11
*** jobs.h	1998/09/10 22:09:11	1.10
--- jobs.h	1999/04/21 11:52:39	1.11
***************
*** 34,40 ****
   * SUCH DAMAGE.
   *
   *	@(#)jobs.h	8.2 (Berkeley) 5/4/95
!  *	$Id: jobs.h,v 1.10 1998/09/10 22:09:11 cracauer Exp $
   */
  
  /* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
--- 34,40 ----
   * SUCH DAMAGE.
   *
   *	@(#)jobs.h	8.2 (Berkeley) 5/4/95
!  *	$Id: jobs.h,v 1.11 1999/04/21 11:52:39 cracauer Exp $
   */
  
  /* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
***************
*** 91,97 ****
  int jobidcmd __P((int, char **));
  struct job *makejob __P((union node *, int));
  int forkshell __P((struct job *, union node *, int));
! int waitforjob __P((struct job *));
  int stoppedjobs __P((void));
  char *commandtext __P((union node *));
  
--- 91,97 ----
  int jobidcmd __P((int, char **));
  struct job *makejob __P((union node *, int));
  int forkshell __P((struct job *, union node *, int));
! int waitforjob __P((struct job *, int *));
  int stoppedjobs __P((void));
  char *commandtext __P((union node *));
  

--OXfL5xGRrasGEqWY--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990802113738.A79295>