diff options
author | David 'Digit' Turner <digit@google.com> | 2009-10-16 12:13:34 -0700 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2009-10-16 12:14:04 -0700 |
commit | 7934a799e1041db9cff9753f4d87d7361f644450 (patch) | |
tree | a2cfc78cfaf898f993a1ef9c2556b3cd012dd0fc /linker | |
parent | 5f32207a3db0bea3ca1c7f4b2b563c11b895f276 (diff) | |
download | bionic-7934a799e1041db9cff9753f4d87d7361f644450.zip bionic-7934a799e1041db9cff9753f4d87d7361f644450.tar.gz bionic-7934a799e1041db9cff9753f4d87d7361f644450.tar.bz2 |
Prevent spurious EINTR to freeze process debugging
Diffstat (limited to 'linker')
-rw-r--r-- | linker/debugger.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/linker/debugger.c b/linker/debugger.c index 5bb065c..1bd3cc8 100644 --- a/linker/debugger.c +++ b/linker/debugger.c @@ -32,6 +32,7 @@ #include <ctype.h> #include <signal.h> #include <sys/mman.h> +#include <errno.h> #include "linker.h" @@ -40,6 +41,11 @@ void notify_gdb_of_libraries(); +#define RETRY_ON_EINTR(ret,cond) \ + do { \ + ret = (cond); \ + } while (ret < 0 && errno == EINTR) + void debugger_signal_handler(int n) { unsigned tid; @@ -58,10 +64,15 @@ void debugger_signal_handler(int n) * is paranoid and will verify that we are giving a tid * that's actually in our process */ - write(s, &tid, sizeof(unsigned)); + int ret; - read(s, &tid, 1); - notify_gdb_of_libraries(); + RETRY_ON_EINTR(ret, write(s, &tid, sizeof(unsigned))); + if (ret == sizeof(unsigned)) { + /* if the write failed, there is no point to read on + * the file descriptor. */ + RETRY_ON_EINTR(ret, read(s, &tid, 1)); + notify_gdb_of_libraries(); + } close(s); } |