From: Denys Vlasenko Date: Mon, 20 Apr 2009 18:20:18 +0000 (+0000) Subject: * strace.c (collect_stopped_tcbs): Do not enable/disable signals X-Git-Tag: v4.5.19~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=246f42ff5ab28f71a08d790352f9411db99e0fb8;p=strace * strace.c (collect_stopped_tcbs): Do not enable/disable signals multiple times, do it just once per collecting pass. --- diff --git a/ChangeLog b/ChangeLog index 0db8a630..6b1fed5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-20 Denys Vlasenko + + * strace.c (collect_stopped_tcbs): Do not enable/disable signals + multiple times, do it just once per collecting pass. + 2009-04-16 Denys Vlasenko * file.c (print_dirfd): Use int for file descriptor, not a long. diff --git a/strace.c b/strace.c index 853288dc..a2bbb670 100644 --- a/strace.c +++ b/strace.c @@ -2284,12 +2284,14 @@ collect_stopped_tcbs(void) nextp = &found_tcps; #endif /* LINUX */ + /* Make it possible to ^C strace while we wait */ + if (interactive) + sigprocmask(SIG_SETMASK, &empty_set, NULL); + found_tcps = NULL; while (1) { if (interrupted) break; - if (interactive) - sigprocmask(SIG_SETMASK, &empty_set, NULL); #ifdef LINUX #ifdef __WALL pid = wait4(-1, &status, wait4_options | wnohang, ru_ptr); @@ -2315,8 +2317,6 @@ collect_stopped_tcbs(void) pid = wait(&status); #endif /* SUNOS4 */ wait_errno = errno; - if (interactive) - sigprocmask(SIG_BLOCK, &blocked_set, NULL); if (pid == 0 && wnohang) { /* We had at least one successful @@ -2435,7 +2435,7 @@ Process %d attached (waiting for parent)\n", if (f == tcp) { remembered_pid = pid; remembered_status = status; - return found_tcps; + goto ret; } f = f->next_need_service; } @@ -2462,6 +2462,10 @@ Process %d attached (waiting for parent)\n", break; #endif } /* while (1) - collecting all stopped/exited tracees */ + ret: + /* Disable ^C etc */ + if (interactive) + sigprocmask(SIG_BLOCK, &blocked_set, NULL); return found_tcps; }