summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-10-19 15:03:31 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-19 15:03:31 -0700
commitb3cfdb6220b9ce8ec6d25984ef086fa06f157236 (patch)
treece8a902b7a6b2b253e1fc2a976ae6f254b2d00b8 /linker
parent5d436ddcae640e2b2af30a5654bec33273b7a9c3 (diff)
parenteeaf6544b676f68ccdd70a3fa78f44789a1bf69c (diff)
downloadbionic-b3cfdb6220b9ce8ec6d25984ef086fa06f157236.tar.gz
bionic-b3cfdb6220b9ce8ec6d25984ef086fa06f157236.tar.bz2
bionic-b3cfdb6220b9ce8ec6d25984ef086fa06f157236.zip
am eeaf6544: Merge change I7934a799 into eclair-mr2
Merge commit 'eeaf6544b676f68ccdd70a3fa78f44789a1bf69c' into eclair-mr2-plus-aosp * commit 'eeaf6544b676f68ccdd70a3fa78f44789a1bf69c': Prevent spurious EINTR to freeze process debugging
Diffstat (limited to 'linker')
-rw-r--r--linker/debugger.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/linker/debugger.c b/linker/debugger.c
index 5bb065c6c..1bd3cc8cd 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);
}