aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-02-27 14:44:16 +0000
committerPedro Alves <palves@redhat.com>2014-02-27 14:44:16 +0000
commit2fa0369e5127bff4ea68b596b1984314feb68299 (patch)
treed38d416063b41265e5598b90bec30c8c7e05e54d /gdb/nat
parent1db37fe62781b677a37acbe801c1e69d8912a124 (diff)
downloadgdb-2fa0369e5127bff4ea68b596b1984314feb68299.zip
gdb-2fa0369e5127bff4ea68b596b1984314feb68299.tar.gz
gdb-2fa0369e5127bff4ea68b596b1984314feb68299.tar.bz2
Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch sigprocmask.
Just a small optimization. No need to block/unblock signals if we're not going to call sigsuspend. gdb/ 2014-02-27 Pedro Alves <palves@redhat.com> * nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG isn't set.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/linux-waitpid.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index e9e69db..4693120 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -92,15 +92,19 @@ my_waitpid (int pid, int *status, int flags)
wnohang = (flags & WNOHANG) != 0;
flags &= ~(__WALL | __WCLONE);
- flags |= WNOHANG;
- /* Block all signals while here. This avoids knowing about
- LinuxThread's signals. */
- sigfillset (&block_mask);
- sigprocmask (SIG_BLOCK, &block_mask, &org_mask);
+ if (!wnohang)
+ {
+ flags |= WNOHANG;
+
+ /* Block all signals while here. This avoids knowing about
+ LinuxThread's signals. */
+ sigfillset (&block_mask);
+ sigprocmask (SIG_BLOCK, &block_mask, &org_mask);
- /* ... except during the sigsuspend below. */
- sigemptyset (&wake_mask);
+ /* ... except during the sigsuspend below. */
+ sigemptyset (&wake_mask);
+ }
while (1)
{
@@ -129,7 +133,8 @@ my_waitpid (int pid, int *status, int flags)
flags ^= __WCLONE;
}
- sigprocmask (SIG_SETMASK, &org_mask, NULL);
+ if (!wnohang)
+ sigprocmask (SIG_SETMASK, &org_mask, NULL);
}
else
{