⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sigsend.c

📁 linux父子进程间关系
💻 C
字号:
#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#define M  4#define MAX  100int main(int argc, char** argv){    int fd0;    int success,count;    char s[M];    if (argc < 2) {        printf("USEAGE: sigsend PID \n");        exit(0);    }    int ipid;    ipid = atoi(argv[1]);    if (ipid <= 0 )     {        printf("pid error!\n");        exit(1);    }    kill(ipid, SIGUSR2);    printf("Send SIGUSR2\n");    //sleep(5);    while ((fd0 = open("test.txt", O_RDONLY)) < 0)         {             if(errno==ENOENT)             {                 sleep(1);                 continue;             }             write(1, "open fifo file Error!\n",sizeof("open file Error!\n"));             exit(1);         }    count=0;    while(count<=MAX)    {        success=read(fd0,s,M);        success=write(1,s,success);        count=count+success;        if(success<=0)            break;    }    kill(ipid,SIGUSR1);    printf("\nSend SIGUSR1\n");    unlink("test.txt");    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -