Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Signals and threads

Reply
Thread Tools

Signals and threads

 
 
shibu-kundara
Guest
Posts: n/a
 
      11-24-2006
Hi folks,
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,

To solve this problem, i did some experiment in the kernel

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 With Quote
 
 
 
 
mark_bluemel@pobox.com
Guest
Posts: n/a
 
      11-24-2006

shibu-kundara wrote:

> Inspite of all this the last sig handler function is getting called
> when i send the signal to the first thread. Any clue???


yes. Try a group that concentrates on your context - threading on Linux
- rather than the language you've implemented in.
comp.programming.threads may be a good start.

 
Reply With Quote
 
 
 
 
Mark McIntyre
Guest
Posts: n/a
 
      11-24-2006
On 24 Nov 2006 04:05:25 -0800, in comp.lang.c , "shibu-kundara"
<> wrote:

>Hi folks,
>I have a problem using sigaction function in pthread library.


unfortunately threads are offtopic in CLC as they're quite platform
specific and not part of hte C langauge (after all, threads can exist
in all languages). You will need to ask in a group specialising in
programming for your particular platform.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Threads, signals and sockets (on UNIX) geoffbache Python 6 06-11-2007 05:34 PM
Threads and signals Chad J. Schroeder Python 1 11-16-2006 04:20 PM
Signals and threads again Mitko Haralanov Python 0 10-13-2006 06:37 PM
control-c and threads, signals in 2.3 causing all sorts of issues Srikanth Mandava Python 1 02-19-2004 12:41 PM
Signals, threads and the use of SIGUSR1 Gabriele Bartolini C++ 4 10-11-2003 07:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57