Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #318
| From | Bill M <wpmccormick@just_about_everywhere.com> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: threading question |
| Date | 2011-12-14 10:26 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <jcain1$gsa$1@dont-email.me> (permalink) |
| References | <jcae0f$if5$1@dont-email.me> <8762hjp32c.fsf@sapphire.mobileactivedefense.com> |
On 12/14/2011 9:48 AM, Rainer Weikusat wrote:
> Bill M<wpmccormick@just_about_everywhere.com> writes:
>> If I ctrl-c kill an daemon type application, will child threads
>> created by the application also be killed or will they become zombie
>> threads?
>
> There is no such thing as 'a zombie thread', at least not in the sense
> you are using the term (technically, a non-detached thread which has
> exited will become 'a zombie thread' because the return value will be
> kept somewhere until [if ever] another thread calls pthread_join in
> order to receive that. While this is similar to 'zombie processes', I
> haven't seen the term 'zombie thread' anywhere so far).
Right, so if I have a some program ...
pthread_create(&thread, ... )
while(some_condition)
{
...
}
pthread_kill(thread, sig);
pthread_join(thread, *retval);
exit(0);
... and the program is killed, with ctrl-c or some other signal, then
the pthread_join is never called. So I *think* I need to trap signals
and exit the while loop so I can clean up the thread. Stop me here if
I'm not right.
From the Sigaction man page:
POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN.
POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD
can be used to prevent the creation of zombies (see wait(2)).
Nevertheless, the historical BSD and System V behaviors for ignoring
SIGCHLD differ, so that the only completely portable method of ensuring
that terminated children do not become zombies is to catch the SIGCHLD
signal and perform a wait(2) or similar.
So, the way I understand that is that I need to catch SIGCHLD (and
SIG_IGN?) and kill the thread, then wait for it to complete with the
join. So if that's all correct, what sig should be sent with pthread_kill?
Obviously, I'm breaking new ground for myself here, so please let me
know if should be considering something else.
Thanks,
Bill
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-14 09:05 -0600
Re: threading question Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-14 15:48 +0000
Re: threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-14 10:26 -0600
Re: threading question Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-14 16:33 +0000
Re: threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-14 11:12 -0600
Re: threading question Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-14 18:10 +0000
Re: threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-14 13:28 -0600
Re: threading question Richard Kettlewell <rjk@greenend.org.uk> - 2011-12-14 18:30 +0000
Re: threading question Mark <i@dontgetlotsofspamanymore.invalid> - 2011-12-15 15:19 +0000
Re: threading question Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-15 15:42 +0000
Re: threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-15 18:50 -0600
Re: threading question Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-16 03:40 +0000
Re: threading question Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-16 08:23 -0600
csiph-web