etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / ptrace.c
blob01ae974839b8882104c76b1a7e6d05ae8437302e
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <string.h>
6 #include <sys/ptrace.h>
8 int ptrace(int req, pid_t pid, void *addr, int data)
10 message m;
12 memset(&m, 0, sizeof(m));
13 m.m_lc_pm_ptrace.pid = pid;
14 m.m_lc_pm_ptrace.req = req;
15 m.m_lc_pm_ptrace.addr = (vir_bytes)addr;
16 m.m_lc_pm_ptrace.data = data;
17 if (_syscall(PM_PROC_NR, PM_PTRACE, &m) < 0) return(-1);
19 /* There was no error, but -1 is a legal return value. Clear errno if
20 * necessary to distinguish this case. _syscall has set errno to nonzero
21 * for the error case.
23 if (m.m_pm_lc_ptrace.data == -1) errno = 0;
24 return(m.m_pm_lc_ptrace.data);