LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-17-2005, 03:29 PM   #1
chuckleberry
LQ Newbie
 
Registered: May 2005
Posts: 23

Rep: Reputation: 15
How to tell when a Pthread finishes (without waiting for it)


Hullo, I have a c++ object wrapped around a pthread. It works perfectly. The thread class is connected to a button in a gui. Is there anyway to signal the main gui thread when the processing thread has completed? I can't wait for the thread to terminate as the processing can take up to 30 seconds. I need to use the gui while the thread is processing its data but I would like to know when it finishes. Feels like I need an event or something but I can't find much in the pthread man pages to help me. I did see a reference to pthread_signal but when I looked at the man page for pthread_sigaction I couldn't really make sense of how to use it. Don't think I'm asking too much of pthread, someone in the know help me out?

<Additional>I don't want to have to constantly poll the thread to check its status and placing a reference to the GUI in the thread class would increase coupling a bit too much for my liking.
Ugh I take it this is a synchronization/condition variable problem, nerts.

Last edited by chuckleberry; 08-17-2005 at 03:42 PM.
 
Old 08-17-2005, 03:59 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"Is there anyway to signal the main gui thread when the processing thread has completed? I can't wait for the thread to terminate as the processing can take up to 30 seconds. I need to use the gui while the thread is processing its data but I would like to know when it finishes. Feels like I need an event or something but I can't find much in the pthread man pages to help me. I did see a reference to pthread_signal but when I looked at the man page for pthread_sigaction I couldn't really make sense of how to use it."

You need to catch a SIGCHLD signal, signal 17.

http://www.comptechdoc.org/os/linux/...pgsignals.html

-------------------------
Steve Stites
 
Old 08-17-2005, 04:05 PM   #3
chuckleberry
LQ Newbie
 
Registered: May 2005
Posts: 23

Original Poster
Rep: Reputation: 15
Thank you very much sir.
 
  


Reply



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
Hard Drive Problems: timeout waiting for DMA; error waiting for DMA mintee Linux - Hardware 10 09-21-2007 05:06 AM
Cron job stopping before it finishes melk600 Linux - Newbie 7 04-23-2007 01:53 AM
How do you automatically power off after a program finishes? cscott Linux - Software 7 03-14-2005 03:36 AM
kdeinit - How do I flush this from memory after app finishes? Devyn Linux - Software 0 01-09-2005 09:45 AM
Epson printer never finishes printing lobo78 Linux - Hardware 0 08-15-2004 01:32 AM

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

All times are GMT -5. The time now is 03:24 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