Fix deadlock when killing adb bugreport
Leave default signal handler (terminate) for parent process, add SIG_IGN as signal handler for children and let them go down when the parent gets SIGPIPE. Bug: 17109154 Change-Id: Id33db3e97a32f289eb2a9a1a0ca8acbe3dcd285d
This commit is contained in:
parent
61a4eecbe6
commit
2e671bbdb7
@ -378,8 +378,8 @@ static void usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void sigpipe_handler(int n) {
|
static void sigpipe_handler(int n) {
|
||||||
(void)n;
|
// don't complain to stderr or stdout
|
||||||
exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@ -404,10 +404,12 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
ALOGI("begin\n");
|
ALOGI("begin\n");
|
||||||
|
|
||||||
|
|
||||||
memset(&sigact, 0, sizeof(sigact));
|
memset(&sigact, 0, sizeof(sigact));
|
||||||
sigact.sa_handler = sigpipe_handler;
|
sigact.sa_handler = sigpipe_handler;
|
||||||
sigaction(SIGPIPE, &sigact, NULL);
|
sigaction(SIGPIPE, &sigact, NULL);
|
||||||
|
|
||||||
|
|
||||||
/* set as high priority, and protect from OOM killer */
|
/* set as high priority, and protect from OOM killer */
|
||||||
setpriority(PRIO_PROCESS, 0, -20);
|
setpriority(PRIO_PROCESS, 0, -20);
|
||||||
FILE *oom_adj = fopen("/proc/self/oom_adj", "w");
|
FILE *oom_adj = fopen("/proc/self/oom_adj", "w");
|
||||||
|
@ -313,6 +313,12 @@ int run_command(const char *title, int timeout_seconds, const char *command, ...
|
|||||||
/* make sure the child dies when dumpstate dies */
|
/* make sure the child dies when dumpstate dies */
|
||||||
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
||||||
|
|
||||||
|
/* just ignore SIGPIPE, will go down with parent's */
|
||||||
|
struct sigaction sigact;
|
||||||
|
memset(&sigact, 0, sizeof(sigact));
|
||||||
|
sigact.sa_handler = SIG_IGN;
|
||||||
|
sigaction(SIGPIPE, &sigact, NULL);
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, command);
|
va_start(ap, command);
|
||||||
if (title) printf("------ %s (%s", title, command);
|
if (title) printf("------ %s (%s", title, command);
|
||||||
|
Loading…
Reference in New Issue
Block a user