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

📄 s8_signal.c

📁 tornado2.2开发
💻 C
字号:
#include "vxWorks.h"
#include "taskLib.h"
#include "sigLib.h"
#include "stdio.h"

SEM_ID semMutex;
int sigflag = 0;

static void catchSIGINT(int signal)
{
    logMsg("sigcatcher:I got this sig %d\n",signal,0,0,0,0,0);
    sigflag=1;
}

static void sigCatcher(void)
{
    struct sigaction newAction;
    int i;
    newAction.sa_handler=catchSIGINT;
    sigemptyset(&newAction.sa_mask);
    newAction.sa_flags = 0;
    if (sigaction(SIGINT,&newAction,NULL) == -1)
    {
        logMsg("Could not install signal handler.\n",0,0,0,0,0,0);
    }
    logMsg("sigCatcher: install signal handler success.\n",0,0,0,0,0,0);
    semGive(semMutex);
    for (i=0;i<15;i++)
    {
        logMsg("sigCatcher:I am doing some work.\n",0,0,0,0,0,0);
    }
    logMsg("sigCatcher: I exit.\n",0,0,0,0,0,0);
}

void s8_signal(void)
{
    int i,j,taskId;
    STATUS taskAlive;
    semMutex = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY);
    if ((taskId = taskSpawn("signal",100,0x100,20000,
          (FUNCPTR)sigCatcher,0,0,0,0,0,0,0,0,0,0))==ERROR)
    { 
        logMsg("taskSpawn sigCatcher failed.\n",0,0,0,0,0,0);
    }
    semTake (semMutex,WAIT_FOREVER);
    logMsg("sigSender:I send SIGINT.\n",0,0,0,0,0,0);
    kill(taskId,SIGINT);
    logMsg("sigSender: I exit.\n",0,0,0,0,0,0);
}

⌨️ 快捷键说明

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