From: "Éric Brunet" <ebrunet@quatramaran.ens.fr>
To: linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: Re: Children first in fork
Date: Fri, 20 Apr 2001 12:13:12 +0200 [thread overview]
Message-ID: <200104201013.MAA03512@quatramaran.ens.fr> (raw)
In-Reply-To: <9bn90l$anp$1@penguin.transmeta.com>
In-Reply-To: <20010419133538.A28654@quatramaran.ens.fr> <NCBBLIEPOCNJOAEKBEAKAEEJOHAA.davids@webmaster.com> <200104191256.OAA31141@quatramaran.ens.fr> <9bn3sr$fer$1@picard.cistron.nl> <9bn90l$anp$1@penguin.transmeta.com>
In ens.mailing-lists.linux-kernel, you wrote:
>You're probably even better off just intercepting the fork, turning it
>into a clone, and setting the CLONE_PTRACE option. Which (together with
>tracing the parent, which you will obviously be doing already in order
>to do all this in the first place) will nicely cause the child to get an
>automatic SIGSTOP _and_ be already traced.
Well, I tried that, and it doesn't work. The problem is that the child
starts ptraced, but it is its parent that will receive a signal for each
syscall, and not the program that ptraces its parent. Of course, the
parent will probably be a little bit confused by that (as it doesn't expect
to receive those signals) and the monitoring programm won't see anything.
Maybe it would work if the function copy_flags in fork.c was modified
into:
-----------------------------------------------------------------
--- fork-old.c Fri Apr 20 12:01:09 2001
+++ fork.c Fri Apr 20 12:05:57 2001
@@ -552,8 +552,14 @@
new_flags &= ~(PF_SUPERPRIV | PF_USEDFPU | PF_VFORK);
new_flags |= PF_FORKNOEXEC;
- if (!(clone_flags & CLONE_PTRACE))
+ if (!(clone_flags & CLONE_PTRACE)) {
new_flags &= ~(PF_PTRACED|PF_TRACESYS);
+ if (p->p_pptr->flags &= PF_PTRACED) {
+ REMOVE_LINKS(p);
+ p->p_pptr = p->p_pptr->p_pptr;
+ SET_LINKS(child);
+ }
+ }
if (clone_flags & CLONE_VFORK)
new_flags |= PF_VFORK;
p->flags = new_flags;
-----------------------------------------------------------------
(sorry, it is a 2.2.19pre8 kernel, and I don't know what have changed
since in that file)
Ok, I haven't tried it (can't reboot a machine now), and I don't know
what I am talking about, but the idea is simply ``if CLONE_PTRACE is set,
and the parent is ptraced, then the child's effective parent should be
its grandfather.''
Was it the way it was intended to work ? As it is now, I don't see any
use of the CLONE_PTRACE flag.
Éric Brunet
next prev parent reply other threads:[~2001-04-20 10:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-19 11:35 Éric Brunet
2001-04-19 12:07 ` David Schwartz
2001-04-19 12:56 ` Éric Brunet
2001-04-19 16:31 ` Wichert Akkerman
2001-04-19 17:58 ` Linus Torvalds
2001-04-20 7:46 ` Wichert Akkerman
2001-04-20 10:27 ` Thomas Pornin
2001-04-20 10:13 ` Éric Brunet [this message]
2001-04-20 17:47 ` Linus Torvalds
2001-04-20 14:56 Mark Kettenis
2001-04-20 17:49 ` Linus Torvalds
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=200104201013.MAA03512@quatramaran.ens.fr \
--to=ebrunet@quatramaran.ens.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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
all inboxes | Powered by JetHome®