Linux/QNX/线程挂起/恢复应用例子
作者:互联网
/*
file name:a.c
date : Wed 26 Jan 2022 04:13:05 AM EST
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <pthread.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include <signal.h>
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void task_sighandler(int sig)
{
pthread_mutex_t mutex = {0};
if(SIGUSR1 != sig)
{
/* null */
}
else
{
/* stop task */
pthread_cond_wait( &cond, &mutex);
}
}
void *task (void *arg)
{
signal(SIGUSR1, task_sighandler);
while(1)
{
printf("%s runing.\n", __func__);
usleep(500*1000);
标签:task,void,pthread,QNX,cond,mutex,Linux,线程,include 来源: https://blog.csdn.net/m0_37132481/article/details/122716209