added calls to "ptraced(pid)" and "unptraced(pid)" to make
authorMark Linton <linton@ucbvax.Berkeley.EDU>
Mon, 8 Aug 1983 09:31:42 +0000 (01:31 -0800)
committerMark Linton <linton@ucbvax.Berkeley.EDU>
Mon, 8 Aug 1983 09:31:42 +0000 (01:31 -0800)
pwait (in library.c) ignore spurious returns from wait -- this caused
a rather annoying bug to occur when doing a "sh" command

SCCS-vsn: old/dbx/process.c 1.11

usr/src/old/dbx/process.c

index b12ed6e..de2ec3a 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)process.c 1.10 %G%";
+static char sccsid[] = "@(#)process.c 1.11 %G%";
 
 /*
  * Process management.
 
 /*
  * Process management.
@@ -80,6 +80,8 @@ private struct Process pbuf;
 
 #define MAXNCMDARGS 100         /* maximum number of arguments to RUN */
 
 
 #define MAXNCMDARGS 100         /* maximum number of arguments to RUN */
 
+extern int errno;
+
 private Boolean just_started;
 private int argc;
 private String argv[MAXNCMDARGS];
 private Boolean just_started;
 private int argc;
 private String argv[MAXNCMDARGS];
@@ -460,6 +462,8 @@ Address addr;
 
 public printstatus()
 {
 
 public printstatus()
 {
+    int status;
+
     if (process->status == FINISHED) {
        exit(0);
     } else {
     if (process->status == FINISHED) {
        exit(0);
     } else {
@@ -704,17 +708,19 @@ String infile;
 String outfile;
 {
     int status;
 String outfile;
 {
     int status;
+    Fileid in, out;
 
     if (p->pid != 0) {                 /* child already running? */
        ptrace(PKILL, p->pid, 0, 0);    /* ... kill it! */
 
     if (p->pid != 0) {                 /* child already running? */
        ptrace(PKILL, p->pid, 0, 0);    /* ... kill it! */
+       pwait(p->pid, &status);         /* wait for it to exit */
+       unptraced(p->pid);
     }
     psigtrace(p, SIGTRAP, true);
     }
     psigtrace(p, SIGTRAP, true);
-    if ((p->pid = vfork()) == -1) {
+    p->pid = vfork();
+    if (p->pid == -1) {
        panic("can't fork");
     }
     if (ischild(p->pid)) {
        panic("can't fork");
     }
     if (ischild(p->pid)) {
-       Fileid in, out;
-
        traceme();
        if (infile != nil) {
            in = open(infile, 0);
        traceme();
        if (infile != nil) {
            in = open(infile, 0);
@@ -747,6 +753,7 @@ String outfile;
     if (p->status != STOPPED) {
        error("program could not begin execution");
     }
     if (p->status != STOPPED) {
        error("program could not begin execution");
     }
+    ptraced(p->pid);
 }
 
 /*
 }
 
 /*
@@ -772,7 +779,7 @@ int signo;
        setinfo(p, signo);
        sigs_off();
        if (ptrace(CONT, p->pid, p->reg[PROGCTR], p->signo) < 0) {
        setinfo(p, signo);
        sigs_off();
        if (ptrace(CONT, p->pid, p->reg[PROGCTR], p->signo) < 0) {
-           panic("can't continue process");
+           panic("error %d trying to continue process", errno);
        }
        pwait(p->pid, &status);
        sigs_on();
        }
        pwait(p->pid, &status);
        sigs_on();