gpt4 book ai didi

SIGABRT 可以通过按键命令生成(就像 SIGINT ctrl+c 一样)吗?

转载 作者:行者123 更新时间:2023-11-30 19:39:10 25 4
gpt4 key购买 nike

我对这个信号主题比较陌生,所以想知道当按下 ctrl+c 时,SIGABRT 是否是由像 SIGINT 这样的键盘命令生成的。任何帮助都会很棒。这是我写的代码:

<小时/>
#include<stdio.h>
#include <sys/types.h>
#include<signal.h>
#include<unistd.h>
#include<stdlib.h>
int c=0;
void hand(int signo)
{
if(signo==SIGINT)
{
c++;
printf("Why the fuck are you interputing me?\n");
}
if(signo==SIGABRT)
{
printf("Why the fuck are you aborting me?bitch!!\n");
kill(getpid(),SIGABRT);
//exit(0);
}
if(signo==SIGKILL)
{
printf("Why the fuck are you killing me?\n");
kill(getpid(),SIGKILL);
}
if(c>5)
{
printf("You execute too many fucking times!!..so now die\n");
kill(getpid(),SIGKILL);
}
}

void main()
{
int i;
if(signal(SIGINT,hand)==SIG_ERR)
printf("Error in catching SIGINT\n");
if(signal(SIGABRT,hand)==SIG_ERR)
printf("Error in catching SIGABRT\n");
if(signal(SIGKILL,hand)==SIG_ERR)
printf("Error in catching SIGKILL\n");
for(i=1;i<50;i++)
{
printf("I'm sleeping...\n");
sleep(2 );
printf("SIGINT sent %d times",c);
}
}

最佳答案

从终端执行以下命令

killall -SIGABRT <your-process>

关于SIGABRT 可以通过按键命令生成(就像 SIGINT ctrl+c 一样)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36862783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com