state(): Handle some races.
authorlace <>
Thu, 12 Apr 2007 19:22:18 +0000 (19:22 +0000)
committerlace <>
Thu, 12 Apr 2007 19:22:18 +0000 (19:22 +0000)
debugger.c

index 81a3bd4..457df84 100644 (file)
@@ -102,7 +102,10 @@ static enum state state_get (pid_t pid)
   if (f == NULL && errno == ENOENT)
     found = STATE_ENOENT;
   else if (f == NULL)
   if (f == NULL && errno == ENOENT)
     found = STATE_ENOENT;
   else if (f == NULL)
-    crash ();
+    {
+      fprintf (stderr, "errno = %d\n", errno);
+      crash ();
+    }
   else
     {
       int i;
   else
     {
       int i;
@@ -131,9 +134,7 @@ static enum state state_get (pid_t pid)
              crash ();
            }
        }
              crash ();
            }
        }
-      if (errno == ESRCH)
-        return found;
-      assert (found != STATE_INSTABLE);
+      assert (found != STATE_INSTABLE || errno == ESRCH);
       i = fclose (f);
       assert (i == 0);
     }
       i = fclose (f);
       assert (i == 0);
     }