How do I determine if I'm being run under the debugger?
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static bool AmIBeingDebugged(void)
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
{
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info.kp_proc.p_flag = 0;
// Initialize mib, which tells sysctl the info we want, in this case
// we're looking for information about a specific process ID.
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();
// Call sysctl.
size = sizeof(info);
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
assert(junk == 0);
// We're being debugged if the P_TRACED flag is set.
return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
}
- Important: Because the definition of the kinfo_proc structure (in <sys/sysctl.h>) is conditionalized by __APPLE_API_UNSTABLE, you should restrict use of the above code to the debug build of your program.
How do I determine if I'm being run under the debugger?的更多相关文章
- Could not determine which “make” command to run. Check the “make” step in the build configuration
环境: QT5.10 VisualStudio2015 错误1: Could not determine which “make” command to run. Check the “make” s ...
- SH Script Grammar
http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...
- allpaths 使用
软件下载与说明:http://www.broadinstitute.org/software/allpaths-lg/blog/?page_id=12 原始数据的深度要达到100以上. 至少要两个库, ...
- Python定时调度--多任务同一时间开始跑 scheduler.enterabs
Event Priorities If more than one event is scheduled for the same time their priority values are use ...
- JUnit扩展:引入新注解Annotation
发现问题 JUnit提供了Test Suite来帮助我们组织case,还提供了Category来帮助我们来给建立大的Test Set,比如BAT,MAT, Full Testing. 那么什么情况下, ...
- 为什么这么多Python框架
原文:http://bitworking.org/news/Why_so_many_Python_web_frameworks BitWorking This is Joe Gregorio's wr ...
- IOS高级开发~开机启动&无限后台运行&监听进程
一般来说, IOS很少给App后台运行的权限. 仅有的方式就是 VoIP. IOS少有的为VoIP应用提供了后台socket连接,定期唤醒并且随开机启动的权限.而这些就是IOS上实现VoIP App的 ...
- HPUX 11.31 MC-SG SGeRAC配置
HPUX 11.31 MC-SG SGeRAC配置 环境: 系统版本号 hp-unix 11.3v2 1503 serviceguard extension版本号 T1907 实施 1. 磁盘空间划分 ...
- RMAN命令DELETE操作总结
本篇总结一下RMAN命令中的DELETE操作,DELETE命令用于删除RMAN备份记录以及相应的物理文件. To delete physical backups and copies as well ...
随机推荐
- SpringMVC+hibernate4事务处理
首先spring-hibernate.xml里配置事务: <!-- 配置事务管理器 --> <bean id="transactionManager" class ...
- python 面向对象 初始化
参考学习: http://www.runoob.com/python/python-object.html 其中 函数里面 self.name 就是用 初始化的 name Employe.empCou ...
- 面试总结之Database
什么是数据库事务? 数据库事务_百度百科 https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BA%8B%E5%8A%A1/9744 ...
- ipython的使用
改初始路径 还有一个坑,可以用notebook打开一个已经存在的文件,但是不能正常编辑(使用单元编辑),因为使用这个创建的东西根本就不是一个.py文件,如果代码编辑完毕,倒是可以通过下载那里选择下载成 ...
- ExtJS动态创建组件
J是代码动态创建dom: 或者 eval有后台组织代码,前台执 ======================= ExtJS组件的动态的创建: 程序中大多数时候需要在后台根据业务逻辑创建符合要求的组件, ...
- lnmp架构实现动态php
目录 LNMP动态网站php 1.PHP-FastCGI概述 PHP-FPM安装配置 配置PHP与数据库连接 配置PHP新增扩展模块 配置PHP-FPM主要配置 配置PHP-FPM错误日志 1.编译安 ...
- 一些linux知识和http知识
1 yum安装比源码编译安装 有的模块不能自定义安装 只能安装默认的模块进行安装 2 关于php的fastcgi 如果使用fastcgi 那么需要启动服务 如果不使用fastcgi 那么不需要启 ...
- MVC框架介绍
第一,建立一个解决方案然后在该解决方案下面新建mvc空项目. 第二,下面先对该项目的一些文件进行介绍: MVC项目文件夹说明: 1.(App_Data):用来保存数据文件,比如XML文件等 2.(Ap ...
- oracle ora-01652无法通过128(在表空间xxx中)扩展 问题解决方式
问题原因建立的表空间dbf文件大小上限了 一. select * from dba_data_files 使用该条语句可以查看当前库中有多少表空间并且DBF文件的存储位置 二.查看表空间是否开启了自动 ...
- window.addEventListener()/window.postMessage(”text“, '*')
1.设置监听 window.addEventListener('message', function (msg) { console.log(msg.data);}) 2.发送 message win ...