2 // NSProcessInfo+Debugging.m
5 // Created by Joe Wreschnig on 3/17/13.
9 #import "NSProcessInfo+Debugging.h"
13 #include <sys/types.h>
15 #include <sys/sysctl.h>
17 @implementation NSProcessInfo (Debugging)
19 - (BOOL)isBeingDebugged {
22 struct kinfo_proc info;
23 size_t size = sizeof(info);
25 info.kp_proc.p_flag = 0;
29 mib[2] = KERN_PROC_PID;
30 mib[3] = self.processIdentifier;
32 return sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) == 0
33 && (info.kp_proc.p_flag & P_TRACED) != 0;