From: daw@mozart.cs.berkeley.edu (David Wagner)
To: linux-kernel@vger.kernel.org
Subject: Re: ptrace vs /proc
Date: 2 Jul 2002 21:16:50 GMT [thread overview]
Message-ID: <aft582$mq0$1@abraham.cs.berkeley.edu> (raw)
In-Reply-To: 20020702004706.GB107@elf.ucw.cz
Pavel Machek wrote:
>I believe such proc interface is wrong thing to do. ptrace() is really
>very *very* special thing, and you don't want it hidden in some kind
>of /proc magic.
Five years ago I believed all that mattered was the functionality:
whether it was exposed via ptrace() and signals or via /proc and ioctls
was irrelevant. Since then, having spent a lot of time using both Linux
ptrace() and Solaris /proc, I've learned that there is a huge difference
between the two. The Solaris implementation, via /proc, is very clean.
The Linux implementation, via ptrace(), is icky.
For example, ptrace() uses signals as part of its interface; this
is a gross kludgy hack, and it breaks various things. For instance,
overloading the meaning of signals causes wait4() to break in the traced
process, and you have to do all sorts of workarounds in the tracer
to make tracing transparent. Go read the source code to strace(1).
I think if you spend the time to understand it all, you'll agree with
me that it is sadly hairy stuff.
The Solaris /proc implementation, in contrast, was much cleaner,
in my experience. I suspect this is partially because the Solaris
implementation was more carefully thought-through, but also the interface
helped: by not overloading the meaning of signals, the Solaris /proc
interface avoids changing the semantics of signal-related functionality
in the traced process, and this makes for cleaner code.
Solaris /proc also had other nice features, like the ability to follow
fork() automatically and so on. (Check out what strace has to do with
ptrace(): it actually does binary code-rewriting of the traced process
on the fly to work around lack of functionality in ptrace().) Many of
these features, of course, were orthogonal to whether the process tracing
was implemented via ptrace() and signals or /proc and ioctls.
next prev parent reply other threads:[~2002-07-02 21:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-20 21:10 ptrace vs /proc Pradeep Padala
2002-06-20 21:36 ` Andrew D Kirch
2002-06-20 21:46 ` Pradeep Padala
2002-06-20 21:49 ` Robert Love
2002-06-21 2:08 ` Pradeep Padala
2002-07-02 0:47 ` Pavel Machek
2002-07-02 21:16 ` David Wagner [this message]
2002-07-03 1:18 ` Pradeep Padala
2002-07-03 3:45 ` Pavel Machek
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='aft582$mq0$1@abraham.cs.berkeley.edu' \
--to=daw@mozart.cs.berkeley.edu \
--cc=linux-kernel@vger.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