2011-10-11 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Tue, 11 Oct 2011 13:58:18 +0000 (13:58 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 11 Oct 2011 13:58:18 +0000 (13:58 +0000)
gdb/
* linux-nat.c (linux_lwp_is_zombie): Return early if the LWP is
not zombie instead of reading the whole file.

gdb/ChangeLog
gdb/linux-nat.c

index fc4e9ddf5dbff8566690578fe49c6a36d7c76b30..3aedc62eea105d33bba74bd11484d963ced827c1 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-11  Pedro Alves  <pedro@codesourcery.com>
+
+       * linux-nat.c (linux_lwp_is_zombie): Return early if the LWP is
+       not zombie instead of reading the whole file.
+
 2011-10-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Fix separate debuginfo warning with "remote:" access.
index 411afdc66bb1bfa2e2e982370a11d31abb5cf257..5c801141aba646f2900c56be42688e7b31731f5e 100644 (file)
@@ -2382,7 +2382,8 @@ linux_lwp_is_zombie (long lwp)
 {
   char buffer[MAXPATHLEN];
   FILE *procfile;
-  int retval = 0;
+  int retval;
+  int have_state;
 
   xsnprintf (buffer, sizeof (buffer), "/proc/%ld/status", lwp);
   procfile = fopen (buffer, "r");
@@ -2391,14 +2392,17 @@ linux_lwp_is_zombie (long lwp)
       warning (_("unable to open /proc file '%s'"), buffer);
       return 0;
     }
+
+  have_state = 0;
   while (fgets (buffer, sizeof (buffer), procfile) != NULL)
-    if (strcmp (buffer, "State:\tZ (zombie)\n") == 0)
+    if (strncmp (buffer, "State:", 6) == 0)
       {
-       retval = 1;
+       have_state = 1;
        break;
       }
+  retval = (have_state
+           && strcmp (buffer, "State:\tZ (zombie)\n") == 0);
   fclose (procfile);
-
   return retval;
 }
 
This page took 0.041711 seconds and 4 git commands to generate.