Re: Am I Being Debugged?
Re: Am I Being Debugged?
- Subject: Re: Am I Being Debugged?
- From: glenn andreas <email@hidden>
- Date: Mon, 8 Oct 2007 16:10:51 -0500
On Oct 8, 2007, at 3:12 PM, Michael Crawford wrote:
Is there an API that allows an application to know that
it's being run under GDB?
#include <sys/sysctl.h>
#include <unistd.h>
int mib[4];
size_t bufSize = 0;
int local_error = 0;
struct kinfo_proc kp;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
bufSize = sizeof (kp);
if ((local_error = sysctl(mib, 4, &kp, &bufSize, NULL, 0)) < 0) {
fprintf(stderr,"Failure calling sysctl");
} else if (kp.kp_proc.p_flag & P_TRACED) {
printf ("I am traced\n");
} else {
printf ("I am not traced\n");
}
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures,
fractals, art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden