rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Byron Rakitzis <byron>
To: rc
Subject: redirection bug
Date: Tue, 11 Feb 1992 22:38:44 -0600	[thread overview]
Message-ID: <92Feb11.223854cst.45331@archone.tamu.edu> (raw)

Here's the patch to the extra-fork redirection bug that Chris just
mentioned:

(this patch comprises all the changes made to walk.c since rc-1.3beta,
but fortunately there is just one other minor change in addition to this
one:)

*** beta/walk.c	Tue Feb 11 22:35:48 1992
--- walk.c	Tue Feb 11 22:23:27 1992
***************
*** 12,18 ****
  bool cond = FALSE;
  
  static bool isallpre(Node *);
! static bool dofork(void);
  static void dopipe(Node *);
  
  /* Tail-recursive version of walk() */
--- 12,18 ----
  bool cond = FALSE;
  
  static bool isallpre(Node *);
! static bool dofork(bool);
  static void dopipe(Node *);
  
  /* Tail-recursive version of walk() */
***************
*** 42,48 ****
  	case nNowait: {
  		int pid;
  		if ((pid = rc_fork()) == 0) {
- 			int fd;
  			setsigdefaults();
  #if defined(SIGTTOU) && defined(SIGTTIN) && defined(SIGTSTP)
  			rc_signal(SIGTTOU, SIG_IGN);	/* Berkeleyized version: put it in a new pgroup. */
--- 42,47 ----
***************
*** 52,59 ****
  #else
  			rc_signal(SIGINT, SIG_IGN);	/* traditional backgrounding procedure: ignore SIGINT */
  #endif
! 			fd = rc_open("/dev/null", rFrom);
! 			mvfd(fd, 0);
  			walk(n->u[0].p, FALSE);
  			exit(getstatus());
  		}
--- 51,57 ----
  #else
  			rc_signal(SIGINT, SIG_IGN);	/* traditional backgrounding procedure: ignore SIGINT */
  #endif
! 			mvfd(rc_open("/dev/null", rFrom), 0);
  			walk(n->u[0].p, FALSE);
  			exit(getstatus());
  		}
***************
*** 141,147 ****
  		break;
  	}
  	case nSubshell:
! 		if (dofork()) {
  			setsigdefaults();
  			walk(n->u[0].p, TRUE);
  			rc_exit(getstatus());
--- 139,145 ----
  		break;
  	}
  	case nSubshell:
! 		if (dofork(TRUE)) {
  			setsigdefaults();
  			walk(n->u[0].p, TRUE);
  			rc_exit(getstatus());
***************
*** 233,239 ****
  	case nBrace:
  		if (n->u[1].p == NULL) {
  			WALK(n->u[0].p, TRUE);
! 		} else if (dofork()) {
  			setsigdefaults();
  			walk(n->u[1].p, TRUE); /* Do redirections */
  			redirq = NULL;   /* Reset redirection queue */
--- 231,237 ----
  	case nBrace:
  		if (n->u[1].p == NULL) {
  			WALK(n->u[0].p, TRUE);
! 		} else if (dofork(parent)) {
  			setsigdefaults();
  			walk(n->u[1].p, TRUE); /* Do redirections */
  			redirq = NULL;   /* Reset redirection queue */
***************
*** 273,283 ****
     waits for the child to finish, setting $status appropriately.
  */
  
! static bool dofork() {
  	void (*handler)(int);
  	int pid, sp;
  
! 	if ((pid = rc_fork()) == 0)
  		return TRUE;
  	redirq = NULL; /* clear out the pre-redirection queue in the parent */
  	fifoq = NULL;
--- 271,281 ----
     waits for the child to finish, setting $status appropriately.
  */
  
! static bool dofork(bool parent) {
  	void (*handler)(int);
  	int pid, sp;
  
! 	if (!parent || (pid = rc_fork()) == 0)
  		return TRUE;
  	redirq = NULL; /* clear out the pre-redirection queue in the parent */
  	fifoq = NULL;


             reply	other threads:[~1992-02-12  4:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-02-12  4:38 Byron Rakitzis [this message]
1992-02-12 16:37 Tom Culliton x2278
1992-03-20 17:57 schwartz
1992-03-20 19:17 ` Brendan Kehoe
1992-03-20 19:27 Byron Rakitzis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92Feb11.223854cst.45331@archone.tamu.edu \
    --to=rc@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).