From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1950364AbcHROiK (ORCPT ); Thu, 18 Aug 2016 10:38:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57434 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1947243AbcHROiI (ORCPT ); Thu, 18 Aug 2016 10:38:08 -0400 Date: Thu, 18 Aug 2016 16:37:50 +0200 From: Oleg Nesterov To: Keno Fischer Cc: roland@hack.frob.com, linux-kernel@vger.kernel.org, Tejun Heo Subject: Re: ptrace group stop signal number not reset before PTRACE_INTERRUPT is delivered? Message-ID: <20160818143750.GA24070@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Aug 2016 14:38:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > #include > #include > #include > #include > #include > #include > #include > > 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); > } > ```