Signals and threads - Embedded

This is a discussion on Signals and threads - Embedded ; Hi I have a problem using sigaction function in pthread library. I have 2 thread each one registering in threadA act1.sa_handler=func1; if(sigaction(SIGUSR1,&act1,NULL)) printf("\nSigaction failed! in th1 !!\n"); in threadB act1.sa_handler=func2; if(sigaction(SIGUSR1,&act2,NULL)) printf("\nSigaction failed! in th2 !!\n"); but when i send ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Signals and threads

  1. Signals and threads

    Hi

    I have a problem using sigaction function in pthread library.
    I have 2 thread each one registering

    in threadA
    act1.sa_handler=func1;
    if(sigaction(SIGUSR1,&act1,NULL)) printf("\nSigaction failed! in th1
    !!\n");

    in threadB
    act1.sa_handler=func2;
    if(sigaction(SIGUSR1,&act2,NULL)) printf("\nSigaction failed! in th2
    !!\n");

    but when i send signal SIGUSR1 to threadA , threadA receives the
    signal
    but the handler func2 is getting called,


    Please let me know is there any way to solve this problem?
    thanks in advance
    thomas


  2. Re: Signals and threads

    shibu-kundara wrote:
    > I have a problem using sigaction function in pthread library.
    > I have 2 thread each one registering
    > but when i send signal SIGUSR1 to threadA , threadA receives the
    > signal but the handler func2 is getting called,



    See the thread "Communication between threads of same PIDs" in this
    forum. Does that help ?

  3. Re: Signals and threads


    Michael Schnell wrote:

    > See the thread "Communication between threads of same PIDs" in this
    > forum. Does that help ?


    thanks for the response,
    It does not solve the problem.

    In the pthread_library clone call is used , In the man page of clone
    its given that
    if CLONE_SIGHAND is not defined, the signal handlers will not be shared
    between threads.
    I recompiled the pthread library with out CLONE_SIGHAND .

    I linked the program with the new library , It has been ok in the
    do_fork call in the pthread funciton, A new struct of task_struct->sig
    is allocated. Also i have seen that the sigaction function call in the
    thread modifies and install a new handler in this already allocated
    task_struct->sig structure.
    Inspite of all this the last sig handler function is getting called
    when i send the signal to the first thread. Any clue???

    thanks
    thomas


+ Reply to Thread