LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-12-2004, 09:44 AM   #1
anoop_cv
LQ Newbie
 
Registered: Oct 2004
Location: Kerala, India
Distribution: Debian
Posts: 3

Rep: Reputation: 0
Signal Handling in Threads[POSIX]


I have written a small program with 3 threads. All the threads have an infinite while loop in which it prints something. I have registered a SIGINT handler in main before creating any thread, in which i just do a print message & then exit(0). The main() just creates these threads and wait for them to join. the problem is that even if i press Ctrl-C, the handler is not getting called. It is called only if i keep it pressed for a few seconds. Why is this happening? Also, if i give a sleep(1) in the while loop of all the threads, the handler is getting called immediately. How this behaviour can be explained?
 
Old 11-02-2004, 02:00 AM   #2
Neocoder
LQ Newbie
 
Registered: Nov 2004
Location: Sweden
Posts: 1

Rep: Reputation: 0
This might help

Hi

I have encountered the same problem.

I haven't found the solution but a explanation of why the problem occurs:
http://www.yolinux.com/TUTORIALS/Lin...ixThreads.html

It seems that you have to activate the signal handler on all threads.

This is all I've got so far, hopefully someone else can fill in the rest
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Threads in signal handling shilpig Programming 3 08-20-2009 03:14 AM
About POSIX threads Ephracis Programming 1 12-03-2004 06:33 AM
signal handling (SIGSEGV) in threads Sinner6 Programming 1 11-09-2004 04:52 PM
Signal handling in threads in 2.6 vs. 2.4 kernel dlocke Linux - Software 0 09-29-2004 06:11 PM
I have a problem with POSIX Threads. AndreasA Programming 2 08-11-2003 02:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration