ptrace (process trace system call) on Linux from D

Stanislav Blinov stanislav.blinov at gmail.com
Mon May 7 03:45:12 PDT 2012


On Friday, 4 May 2012 at 14:47:05 UTC, Matej Nanut wrote:
> (1) I've managed this by putting the extern ptrace declaration 
> in a seperate file and call it via filename.ptrace in my 
> program.
>

You can achieve the same without additional files:

// This struct acts as a namespace to hide C declarations,
// just like separate module
struct PtraceApi {
static:

     extern(C) long ptrace(__ptrace_request request, pid_t pid, 
void *addr,
void *data);

}

long ptrace(__ptrace_request request, pid_t pid, void *addr,
void *data) {
     auto result = PtraceApi.ptrace(request, pid, addr, data);
     // Check result and errno for errors...
}


More information about the Digitalmars-d-learn mailing list