ptrace (process trace system call) on Linux from D
Artur Skawina
art.08.09 at gmail.com
Mon May 7 04:30:19 PDT 2012
On 05/07/12 12:45, Stanislav Blinov wrote:
> 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...
> }
>
struct method names are mangled, including static and extern(C) ones.
(they have to be, or you'd get collisions; a way to turn it off for
cases like this one would be useful, yes.)
artur
More information about the Digitalmars-d-learn
mailing list