From: Oleg Nesterov <oleg@redhat.com>
To: Keno Fischer <keno@juliacomputing.com>
Cc: roland@hack.frob.com, linux-kernel@vger.kernel.org,
Tejun Heo <tj@kernel.org>
Subject: Re: ptrace group stop signal number not reset before PTRACE_INTERRUPT is delivered?
Date: Thu, 18 Aug 2016 16:37:50 +0200 [thread overview]
Message-ID: <20160818143750.GA24070@redhat.com> (raw)
In-Reply-To: <CABV8kRx6LQGBvJnR2UtWJbx7P_tjEGn=omhzzL-QVyLYEQPedQ@mail.gmail.com>
On 08/17, Keno Fischer wrote:
>
> In this test case, the last
> group-stop (after PTRACE_INTERRUPT) is delivered with a
> WSTOPSIG(status) of SIGTTIN, which was the signr of the previous group
> stop. From reading the man-page, I would have expected SIGTRAP.
Me too ;)
> Now, I
> understand that if there is another stop pending, PTRACE_INTERRUPT
> will simply piggy-backs off that one, but I don't believe that is
> happening in this case.
Yes, thanks. This is wrong. We need to remove SIGTTIN from jobctl.
The problem, I am not sure when... I'll try to think.
Thanks!
> #include <assert.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <signal.h>
> #include <unistd.h>
> #include <sys/ptrace.h>
> #include <sys/wait.h>
> #include <linux/ptrace.h>
>
> int main() {
> pid_t child, ret;
> int err;
> int status;
> if (0 == (child = fork())) {
> kill(getpid(), SIGSTOP);
> kill(getpid(), SIGSTOP);
> kill(getpid(), SIGTTIN);
> sleep(1000);
> exit(0);
> }
> ret = waitpid(child, &status, WSTOPPED);
> assert(ret == child);
> err = ptrace(PTRACE_SEIZE, child, NULL, NULL);
> assert(err == 0);
> err = ptrace(PTRACE_CONT, child, NULL, NULL);
> assert(err == 0);
> // Should now hit SIGSTOP signal-stop
> ret = waitpid(child, &status, 0);
> assert(ret == child && WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP);
> err = ptrace(PTRACE_CONT, child, NULL, (void*)SIGSTOP);
> assert(err == 0);
> // Should now hit SIGSTOP group-stop
> ret = waitpid(child, &status, 0);
> assert(ret == child && (status>>16 == PTRACE_EVENT_STOP) &&
> WSTOPSIG(status) == SIGSTOP);
> err = ptrace(PTRACE_CONT, child, NULL, NULL);
> assert(err == 0);
> // Should now hit SIGTTIN signal-stop
> ret = waitpid(child, &status, 0);
> assert(ret == child && WIFSTOPPED(status) && WSTOPSIG(status) == SIGTTIN);
> err = ptrace(PTRACE_CONT, child, NULL, (void*)SIGTTIN);
> assert(err == 0);
> // Should now hit SIGTTIN group-stop
> ret = waitpid(child, &status, 0);
> assert(ret == child && (status>>16 == PTRACE_EVENT_STOP) &&
> WSTOPSIG(status) == SIGTTIN);
> err = ptrace(PTRACE_CONT, child, NULL, NULL);
> assert(err == 0);
> // Now interrupt it
> err = ptrace(PTRACE_INTERRUPT, child, NULL, NULL);
> assert(err == 0);
> // Should now hit interrupt group-stop
> ret = waitpid(child, &status, 0);
> printf("Interrupt group-stop delivered with signal %d\n", WSTOPSIG(status));
> assert(ret == child && (status>>16 == PTRACE_EVENT_STOP) &&
> WSTOPSIG(status) == SIGTRAP);
> exit(0);
> }
> ```
next prev parent reply other threads:[~2016-08-18 14:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 3:52 ptrace group stop signal number not reset before PTRACE_INTERRUPT is delivered? Keno Fischer
2016-08-18 14:37 ` Oleg Nesterov [this message]
2016-08-18 15:38 ` Oleg Nesterov
2016-08-18 16:23 ` Oleg Nesterov
2016-08-18 17:37 ` Keno Fischer
2016-08-23 15:34 ` Oleg Nesterov
2016-09-13 21:57 ` Keno Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160818143750.GA24070@redhat.com \
--to=oleg@redhat.com \
--cc=keno@juliacomputing.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@hack.frob.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox