From: Pedro Alves Date: Thu, 27 Feb 2014 14:44:16 +0000 (+0000) Subject: Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch sigprocmask. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2fa0369e5127bff4ea68b596b1984314feb68299;p=binutils-gdb.git 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 * nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG isn't set. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb5f5aa9f04..6cfb9c53dfb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-02-27 Pedro Alves + + * nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG + isn't set. + 2014-02-27 Pedro Alves PR 12702 diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c index e9e69db9717..4693120ef79 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 {