ptrace進程退出狀態跟蹤

ptrace進程退出狀態跟蹤#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <sys/ptrace.h>#include <sys/types.h>#include <sys/wait.h>#include <>int...
摘要由CSDN通过智能技术生成

detach 必須在進程stop狀態下才能退出,如果要detach一個未stop的進程,先用調用:
kill(pid,SIGSTOP);
wait();
ptrace(PTRACE_DETACH,pid,NULL,NULL);

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>

#define PROC_STAT_STOP          "T (stopped)"
#define PROC_STAT_SLEEP         "S (sleeping)"
#define PROC_STAT_RUING         "R (running)"
#define PROC_STAT_DISK_SLEEP    "D (disk sleep)"
#define PROC_STAT_TRACE_STOP    "T (tracing stop)"
#define PROC_STAT_ZOMBIE        "Z (zombie)"
#define PROC_STAT_DEAD          "X (dead)"
#define _PRINT_ERR_             printf("ERRNO:%d INFO:%s\n",errno,strerror(errno));

const char * SIGNAL_NAME[] =
{
  /*0*/ "NO-SIGNAL",                                //sigal start from 1
  /*1*/ "SIGHUP", 
  /*2*/ "SIGINT", 
  /*3*/ "SIGQUIT", 
  /*4*/ "SIGILL", 
  /*5*/ "SIGTRAP", 
  /*6*/ "SIGABRT", 
  /*7*/ "SIGBUS", 
  /*8*/ "SIGFPE", 
  /*9*/ "SIGKILL", 
  /*10*/ "SIGUSR1", 
  /*11*/ "SIGSEGV", 
  /*12*/ "SIGUSR2", 
  /*13*/ "SIGPIPE", 
  /*14*/ "SIGALRM", 
  /*15*/ "SIGTERM", 
  /*16*/ "SIGSTKFLT", 
  /*17*/ "SIGCHLD", 
  /*18*/ "SIGCONT", 
  /*19*/ "SIGSTOP", 
  /*20*/ "SIGTSTP", 
  /*21*/ "SIGTTIN", 
  /*22*/ "SIGTTOU", 
  /*23*/ "SIGURG", 
  /*24*/ "SIGXCPU", 
  /*25*/ "SIGXFSZ", 
  /*26*/ "SIGVTALRM", 
  /*27*/ "SIGPROF", 
  /*28*/ "SIGWINCH", 
  /*29*/ "SIGIO", 
  /*30*/ "SIGPWR", 
  /*31*/ "SIGSYS", 
  /*34*/ "SIGRTMIN", 
  /*35*/ "SIGRTMIN+1", 
  /*36*/ "SIGRTMIN+2", 
  /*37*/ "SIGRTMIN+3", 
  /*38*/ "SIGRTMIN+4", 
  /*39*/ "SIGRTMIN+5", 
  /*40*/ "SIGRTMIN+6", 
  /*41*/ "SIGRTMIN+7", 
  /*42*/ "SIGRTMIN+8", 
  /*43*/ "SIGRTMIN+9", 
  /*44*/ "SIGRTMIN+10", 
  /*45*/ "SIGRTMIN+11", 
  /*46*/ "SIGRTMIN+12", 
  /*47*/ "SIGRTMIN+13", 
  /*48*/ "SIGRTMIN+1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值