Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix attaching to Linux stopped processes
Date: Mon, 25 Sep 2006 10:52:00 -0000	[thread overview]
Message-ID: <20060925105234.GA12295@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <200609231736.k8NHabVs010214@elgar.sibelius.xs4all.nl>

On Sat, 23 Sep 2006 19:36:37 +0200, Mark Kettenis wrote:
...
> > Also the patch looks right to me - after `PT_ATTACH' it is appropriate that
> > `WSTOPSIG (status)' will report the original signal that stopped process,
> > (WSTOPSIG (status) == SIGSTOP) <=> (process was in running/sleeping mode).
> 
> Whoa stop, the status returned by wait(2) doesn't tell you whether a
> process is sleeping or running.  Traditionally, after invoking
> ptrace(PT_ATTACH, ...) the kernel will always respond with a SIGSTOP.
> Any information about any previous signals is lost.

(Red Hat) kernel 2.6.17-1.2647.fc6 reports SIGSTOP for running processes and
0 for processes already stopped before ptrace(PTRACE_ATTACH).  It does not
differentiate SIGTTIN vs. SIGSTOP etc., though, as I expected, thanks.

I found in POSIX that the waitpid(2) vs. ptrace(2) behavior is underfined:
	http://www.opengroup.org/onlinepubs/009695399/functions/wait.html
	Since ptrace() is not part of this volume of IEEE Std 1003.1-2001,
	[ I did not find any other ptrace(2) on http://www.opengroup.org/ . ]


> This all smells like a race condition in the kernel to me.  The
> linux-nat.c code is quite hairy already.  I'd suggest fixing the
> kernel rather than adding more workarounds.

Do you have some standard/specification to follow?
I found more that the WSTOPSIG() _should_ report the specific signal:
	http://www.scit.wlv.ac.uk/cgi-bin/mansec?3B+wait4
	the 8 bits higher up from the low-order 8 bits of w_status contain the
	number of the signal that caused the process to stop.
	See ptrace(2) and sigvec(3UCB).


Regards,
Jan


      reply	other threads:[~2006-09-25 10:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-17 22:12 Jan Kratochvil
2006-09-17 22:26 ` Daniel Jacobowitz
2006-09-18  9:53   ` Jan Kratochvil
2006-09-18 13:16     ` Daniel Jacobowitz
2006-09-18 20:49       ` Jan Kratochvil
2006-09-18 20:54         ` Daniel Jacobowitz
2006-09-23 17:37     ` Mark Kettenis
2006-09-25 10:52       ` Jan Kratochvil [this message]

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=20060925105234.GA12295@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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