From d23074cec9b3759393822c9577af41d474cdd292 Mon Sep 17 00:00:00 2001 From: Greg V Date: Tue, 10 Jul 2018 14:01:54 +0300 Subject: [PATCH] test: ptrace compatibility with *BSD --- meson.build | 6 ++++++ test/litest.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 931681a..b9de111 100644 --- a/meson.build +++ b/meson.build @@ -97,6 +97,12 @@ if cc.has_header('xlocale.h') config_h.set('HAVE_XLOCALE_H', '1') endif +if not cc.has_header_symbol('sys/ptrace.h', 'PTRACE_ATTACH', prefix : prefix) + config_h.set('PTRACE_ATTACH', 'PT_ATTACH') + config_h.set('PTRACE_CONT', 'PT_CONTINUE') + config_h.set('PTRACE_DETACH', 'PT_DETACH') +endif + # Dependencies pkgconfig = import('pkgconfig') dep_udev = dependency('libudev') diff --git a/test/litest.c b/test/litest.c index ae4c160..7febc3b 100644 --- a/test/litest.c +++ b/test/litest.c @@ -3870,10 +3870,10 @@ is_debugger_attached(void) if (pid == 0) { int ppid = getppid(); - if (ptrace(PTRACE_ATTACH, ppid, NULL, NULL) == 0) { + if (ptrace(PTRACE_ATTACH, ppid, NULL, 0) == 0) { waitpid(ppid, NULL, 0); - ptrace(PTRACE_CONT, NULL, NULL); - ptrace(PTRACE_DETACH, ppid, NULL, NULL); + ptrace(PTRACE_CONT, ppid, NULL, 0); + ptrace(PTRACE_DETACH, ppid, NULL, 0); rc = 0; } else { rc = 1; -- 2.7.4