aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-10-11 13:58:18 +0000
committerPedro Alves <palves@redhat.com>2011-10-11 13:58:18 +0000
commitea23808b14438001e2c481a510ca5acb886ca2d4 (patch)
tree50a6a4715b8b6014ad638172249494a7b66b2fee /gdb
parent904578edab299a982654a3ec01709097a6ed5661 (diff)
downloadgdb-ea23808b14438001e2c481a510ca5acb886ca2d4.zip
gdb-ea23808b14438001e2c481a510ca5acb886ca2d4.tar.gz
gdb-ea23808b14438001e2c481a510ca5acb886ca2d4.tar.bz2
2011-10-11 Pedro Alves <pedro@codesourcery.com>
gdb/ * linux-nat.c (linux_lwp_is_zombie): Return early if the LWP is not zombie instead of reading the whole file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/linux-nat.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fc4e9dd..3aedc62 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 411afdc..5c80114 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -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;
}