Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sunybcs!boulder!hao!husc6!ddl From: ddl@husc6.UUCP Newsgroups: comp.os.minix Subject: sh bugs Message-ID: <3461@husc6.harvard.edu> Date: Fri, 4-Dec-87 02:19:43 EST Article-I.D.: husc6.3461 Posted: Fri Dec 4 02:19:43 1987 Date-Received: Sun, 6-Dec-87 22:02:48 EST Organization: Harvard University, Cambridge MA Lines: 49 Keywords: sh bugs fork exec pipe There appear to be a few bugs in the sh clone: 1) sh parses and executes a;b& as if it were (a;b)& That is, the commands a and b are run sequentially but in the background. Fix: change c_list (sh2.c) to something like this: static struct op * c_list() { register struct op *t, *p; register int c; t = andor(); if (t != NULL) { if((peeksym = yylex(0)) == '&') t = block(TASYNC, t, NOBLOCK, NOWORDS); while ((c = yylex(0)) == ';' || c == '&' || multiline && c == '\n') { if ((p = andor()) == NULL) return(t); if((peeksym = yylex(0)) == '&') p = block(TASYNC, p, NOBLOCK, NOWORDS); t = list(t, p); } peeksym = c; } return(t); } 2) (cmd) executes cmd with signals ignored. Fix: change forkexec (sh3.c) such that signals are reset before the check for TPAREN: if (resetsig) { signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); } if (t->type == TPAREN) exit(execute(t->left, NOPIPE, NOPIPE, FEXEC)); 3) Many chances to exec rather than fork a command are missed. Most anoying is that a | b & results in three, rather than two, processes. Fix: It appears that each case of execute (sh3.c) should pass the act flag to its last (or only) recursive invocation of execute. Although this seems to be the intention of the code, I can't be sure it doesn't break anything (works fine for me...) and there may be a problem with freeing memory. Dan Lanciani ddl@harvard.*