[PATCH] USE_SEIZE: fix detaching from stopped processes

Denys Vlasenko dvlasenk at redhat.com
Tue Jun 18 16:22:26 UTC 2013


On 06/18/2013 05:57 PM, Denys Vlasenko wrote:
> The logic was:
> 
>                 else if (!sigstop_expected && my_tkill(tcp->pid, SIGSTOP) < 0) {
>                         if (errno != ESRCH)
>                                 perror_msg("detach: stopping child");
>                 }
>                 else
>                         sigstop_expected = 1;
> 
> which, if my_tkill succeeded, was setting sigstop_expected = 1.
> 
> Now if we send PTRACE_INTERRUPT, we also set sigstop_expected = 1.
> 
> But there will be no SIGSTOP (unless tracee is already stopped, then yes) -
> PTRACE_INTERRUPT generates SIGTRAP-stop!
> 
> I propose the attached patch.
> Sorry, Thunderbird mangles inline patches :(

+			if (error && errno != ESRCH) {
+				if (use_seize)
+					perror_msg("detach: ptrace(PTRACE_INTERRUPT, ...)");
+				else
+					perror_msg("detach: stopping child");
+			} else {
+				sigstop_expected = 1;
+			}

Hmm, my patch sets sigstop_expected = 1 also if we got
an error, but is was ESRCH.

Which is perhaps suboptimal: we should expect a stop
only if PTRACE_INTERRUPT or tkill succeded.

Also, it is no longer sigstop_expected, but rather stop_expected,
since the stop may be not SIGSTOP.

I sent a newer version of the patch. Please let me know what you think.

(I split off and committed a trivial part of the change).

-- 
vda





More information about the Strace-devel mailing list