zoukankan      html  css  js  c++  java
  • linux不同信号之间发送信号测试

    #include<stdio.h>
    #include
    <pthread.h>
    #include
    <stdlib.h>
    #include
    <unistd.h>
    #include
    <signal.h>

    void *test_program(void *arg);

    int main(int argc,char *argv[])
    {
    int i;
    pthread_t thread_id;
    void *status;

    if(pthread_create(&thread_id,NULL,test_program,NULL)>0)
    {
    fprintf(stderr,
    "pthread_create failure\n");
    exit(EXIT_FAILURE);
    }
    sleep(
    5)
    printf(
    "this is parent ,send kill signal to thread %d\n",thread_id);
    if(pthread_kill(thread_id,SIGKILL)!=0)
    {
    perror(
    "pthread_kill");
    exit(EXIT_FAILURE);
    }
    return 0;
    }

    void *test_program(void *arg)
    {
    int i;
    for(i=0;;i++)
    {
    sleep(
    1);
    printf(
    "this is child thread ,%d\n",i);
    printf(
    "wait for kill signal\n");
    }
    exit(EXIT_SUCCESS);
    }
  • 相关阅读:
    Best Time to Buy and Sell Stock II
    Subsets II
    Subsets I
    Combinations
    Permutation Sequence
    Next Permutation
    Anagrams
    Combination-Sum II
    Combination-Sum I
    Permutations II
  • 原文地址:https://www.cnblogs.com/hnrainll/p/2033858.html
Copyright © 2011-2022 走看看