views:

126

answers:

1

Hi, I am trying to detect whether my process is being run in a debugger or not and, while in Windows there are many solutions and in Linux i use

ptrace(PTRACE_ME,0,0,0) 

and check its return value, i did not manage to perform the same basic check on Mac Os X. I tried to use the

`ptrace(PT_TRACE_ME,0,0,0)` 

call but it always returns 0 even when ran under gdb. if I change the request to PT_DENY_ATTACH it correctly stops the debugging but that is not what i want to achieve. Any ideas?

+1  A: 

You can just call the function AmIBeingDebugged().

See Apple Technical Q&A QA1361

Paul R
Thanks, that little code worked just fine, i am still unable to get why ptrace failed miserably though.
Alienpenguin