libexplain  1.4.D001
Functions
libexplain/ptrace_or_die.c File Reference
#include <libexplain/ac/errno.h>
#include <libexplain/ac/sys/ptrace.h>
#include <libexplain/output.h>
#include <libexplain/ptrace.h>

Go to the source code of this file.

Functions

long explain_ptrace_or_die (int request, pid_t pid, void *addr, void *data)
static int ptrace (int request, pid_t pid, void *addr, void *data)
long explain_ptrace_on_error (int request, pid_t pid, void *addr, void *data)

Function Documentation

long explain_ptrace_on_error ( int  request,
pid_t  pid,
void *  addr,
void *  data 
)

The explain_ptrace_on_error function is used to call the ptrace(2) system call. On failure an explanation will be printed to stderr, obtained from the explain_ptrace(3) function.

Parameters:
requestThe request, exactly as to be passed to the ptrace(2) system call.
pidThe pid, exactly as to be passed to the ptrace(2) system call.
addrThe addr, exactly as to be passed to the ptrace(2) system call.
dataThe data, exactly as to be passed to the ptrace(2) system call.
Returns:
The value returned by the wrapped ptrace(2) system call.
Example:
This function is intended to be used in a fashion similar to the following example:
 long result = explain_ptrace_on_error(request, pid, addr, data);
 if (result < 0)
 {
     ...cope with error
     ...no need to print error message
 }

Definition at line 55 of file ptrace_or_die.c.

long explain_ptrace_or_die ( int  request,
pid_t  pid,
void *  addr,
void *  data 
)

The explain_ptrace_or_die function is used to call the ptrace(2) system call. On failure an explanation will be printed to stderr, obtained from the explain_ptrace(3) function, and then the process terminates by calling exit(EXIT_FAILURE).

Parameters:
requestThe request, exactly as to be passed to the ptrace(2) system call.
pidThe pid, exactly as to be passed to the ptrace(2) system call.
addrThe addr, exactly as to be passed to the ptrace(2) system call.
dataThe data, exactly as to be passed to the ptrace(2) system call.
Returns:
This function only returns on success, see ptrace(2) for more information. On failure, prints an explanation and exits, it does not return.
Example:
This function is intended to be used in a fashion similar to the following example:
 long result = explain_ptrace_or_die(request, pid, addr, data);

Definition at line 27 of file ptrace_or_die.c.

static int ptrace ( int  request,
pid_t  pid,
void *  addr,
void *  data 
) [static]

Definition at line 42 of file ptrace_or_die.c.