tests: Disable attach debugger on FreeBSD

Disable attaching a debugger on FreeBSD, since FreeBSD lacks support for
PTRACE_ATTACH.

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
This commit is contained in:
Niclas Zeising 2020-08-10 23:24:34 +02:00
parent 8026722f86
commit 0af8c4054d

View file

@ -38,8 +38,13 @@
static int static int
is_debugger_attached(void) is_debugger_attached(void)
{ {
int rc = 1;
/*
* FreeBSD does not support PTRACE_ATTACH, disable attaching a debugger
* on FreeBSD by skipping the rest of the function and just return 1.
*/
#ifndef __FreeBSD__
int status; int status;
int rc;
int pid = fork(); int pid = fork();
if (pid == -1) if (pid == -1)
@ -52,14 +57,14 @@ is_debugger_attached(void)
ptrace(PTRACE_CONT, NULL, NULL); ptrace(PTRACE_CONT, NULL, NULL);
ptrace(PTRACE_DETACH, ppid, NULL, NULL); ptrace(PTRACE_DETACH, ppid, NULL, NULL);
rc = 0; rc = 0;
} else }
rc = 1;
_exit(rc); _exit(rc);
} else { } else {
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
rc = WEXITSTATUS(status); rc = WEXITSTATUS(status);
} }
#endif /* !__FreeBSD__ */
return rc; return rc;
} }