support SIGSTOP in editor, I cannot believe this has always been busted!
authorderaadt <deraadt@openbsd.org>
Sat, 12 Apr 1997 09:39:58 +0000 (09:39 +0000)
committerderaadt <deraadt@openbsd.org>
Sat, 12 Apr 1997 09:39:58 +0000 (09:39 +0000)
usr.sbin/cron/crontab.c

index 8e179dc..31c5814 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: crontab.c,v 1.8 1996/12/25 19:08:09 mickey Exp $";
+static char rcsid[] = "$Id: crontab.c,v 1.9 1997/04/12 09:39:58 deraadt Exp $";
 #endif
 
 /* crontab - install and manage per-user crontab files
@@ -424,23 +424,26 @@ edit_cmd() {
        }
 
        /* parent */
-       xpid = wait(&waiter);
-       if (xpid != pid) {
-               fprintf(stderr, "%s: wrong PID (%d != %d) from \"%s\"\n",
-                       ProgramName, xpid, pid, editor);
-               goto fatal;
-       }
-       if (WIFEXITED(waiter) && WEXITSTATUS(waiter)) {
-               fprintf(stderr, "%s: \"%s\" exited with status %d\n",
-                       ProgramName, editor, WEXITSTATUS(waiter));
-               goto fatal;
-       }
-       if (WIFSIGNALED(waiter)) {
-               fprintf(stderr,
-                       "%s: \"%s\" killed; signal %d (%score dumped)\n",
-                       ProgramName, editor, WTERMSIG(waiter),
-                       WCOREDUMP(waiter) ?"" :"no ");
-               goto fatal;
+       while (1) {
+               xpid = waitpid(pid, &waiter, WUNTRACED);
+               if (xpid != pid) {
+                       fprintf(stderr, "%s: wrong PID (%d != %d) from \"%s\"\n",
+                               ProgramName, xpid, pid, editor);
+                       goto fatal;
+               } else if (WIFSTOPPED(waiter)) {
+                       raise(WSTOPSIG(waiter));
+               } else if (WIFEXITED(waiter) && WEXITSTATUS(waiter)) {
+                       fprintf(stderr, "%s: \"%s\" exited with status %d\n",
+                               ProgramName, editor, WEXITSTATUS(waiter));
+                       goto fatal;
+               } else if (WIFSIGNALED(waiter)) {
+                       fprintf(stderr,
+                               "%s: \"%s\" killed; signal %d (%score dumped)\n",
+                               ProgramName, editor, WTERMSIG(waiter),
+                               WCOREDUMP(waiter) ?"" :"no ");
+                       goto fatal;
+               } else
+                       break;
        }
        if (fstat(t, &statbuf) < 0) {
                perror("fstat");