Prevent spurious EINTR to freeze process debugging
This commit is contained in:
parent
5f32207a3d
commit
7934a799e1
@ -32,6 +32,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "linker.h"
|
#include "linker.h"
|
||||||
|
|
||||||
@ -40,6 +41,11 @@
|
|||||||
|
|
||||||
void notify_gdb_of_libraries();
|
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)
|
void debugger_signal_handler(int n)
|
||||||
{
|
{
|
||||||
unsigned tid;
|
unsigned tid;
|
||||||
@ -58,10 +64,15 @@ void debugger_signal_handler(int n)
|
|||||||
* is paranoid and will verify that we are giving a tid
|
* is paranoid and will verify that we are giving a tid
|
||||||
* that's actually in our process
|
* that's actually in our process
|
||||||
*/
|
*/
|
||||||
write(s, &tid, sizeof(unsigned));
|
int ret;
|
||||||
|
|
||||||
read(s, &tid, 1);
|
RETRY_ON_EINTR(ret, write(s, &tid, sizeof(unsigned)));
|
||||||
notify_gdb_of_libraries();
|
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);
|
close(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user