ptrace (process trace system call) on Linux from D
Matej Nanut
matejnanut at gmail.com
Thu May 3 11:00:50 PDT 2012
Thank you for the reply, your recommendation works.
I could however not find ptrace anywhere in druntime. There is
only one mention of it in std.process, in a comment.
But I do have some other questions:
(1) Can I declare a ptrace function which calls the original
ptrace? (I would like to check the return value and errno for
exception throwing and such). I essentially want to shadow the
original.
(2) Is it more D-ish to use something like "enum PTRequest {
traceMe = 0, ... }" instead of the fully capitalised originals?
It doesn't seem to affect the working of things.
(3) wait() is declared as returning a pid_t in the manpage, and
is declared as such in core.sys.posix.sys.wait. In std.c.process
however, it returns an int. I can't even find a process.h in my
Linux install. What am I supposed to use? I know it essentially
doesn't matter, as pid_t is aliased as int.
Are there D alternatives to wait() and fork() that I could use
with ptrace() instead of the C posix system functions?
(4) Some things are declared only in core.*, not in std.*. Will
they be added at some point or is this how it's supposed to be?
More information about the Digitalmars-d-learn
mailing list