473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Signals and threads

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

Nov 24 '06 #1
2 2127

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.

Nov 24 '06 #2
On 24 Nov 2006 04:05:25 -0800, in comp.lang.c , "shibu-kundara"
<th*******@gmail.comwrote:
>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
Nov 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sebastian Meyer | last post by:
Hi Newsgroup, i have some problems with using threads and signals in one program. In my program i have three threads running, one for checking a directory at a specified interval to see if new...
2
by: Holger Joukl | last post by:
Hi, migrating from good old python 1.5.2 to python 2.3, I have a problem running a program that features some threads which execute calls to an extension module. Problem is that all of a sudden,...
1
by: Frank Bossy | last post by:
Dear group :) I don't quite understand the meaning of this paragraph in the qt docu (http://doc.trolltech.com/3.1/threads.html): ***SNIP The Signals and Slots mechanism can be used in...
4
by: Gabriele Bartolini | last post by:
Hi, I am writing an application in C++ on Linux, using threads (this is my first experience with pthreads). The application itself is fine, it is just that I wanted to handle asynchronous...
0
by: Mitko Haralanov | last post by:
Hi everyone, First off, I know that this has been discussed before and I did a search but could not find anything that helped my situation. Here is the problem: I have a Python program that...
1
by: Chad J. Schroeder | last post by:
I've run into an "opportunity" in a Python application using threads and signals. Basically, there is a main process that spawns off a child thread that loops forever. In between iterations, the...
0
by: Lloyd Zusman | last post by:
I have a python-2.5 program running under linux in which I spawn a number of threads. The main thread does nothing while these subsidiary threads are running, and after they all complete, the main...
6
by: geoffbache | last post by:
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received,...
11
by: vippstar | last post by:
What is the purpose of signals and why do they exist in C? thanks in advance
1
by: Jean-Paul Calderone | last post by:
On Sat, 17 May 2008 12:49:54 -0700, John Schroeder <jschroed@gmail.comwrote: Look at that program. It's single-threaded. Where do you think the ^C is going? :) Jean-Paul
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.