Skip to contentSkip to conversation

[email protected]

DISCUSSION Sudarshan Soma 1 participant 1 message May 18, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

It looks like i can't call exit(-1)in signal handlers as its Asynchronous—signal-safe function. As my application wont register any exit handler functions, is this safe to use??

Please suggest if there are better alternatives.

Quoted 52 lines · Sudarshan Soma

--- On Sat, 16/5/09, Robert Hancock <[email protected]> wrote:

From: Robert Hancock <[email protected]>
Subject: Re: patch related to SIGSEGV handling in multiple threads
and hung threads
To: "Sudarshan Soma" <[email protected]>
Cc: [email protected]
Date: Saturday, 16 May, 2009, 6:45 AM

Quoted 15 lines · Sudarshan Soma

Hi ,
I have a program which will create multiple threads. One of the thread receives SIGSEGV and it prints stacktrace in its handler and calls _exit(-1). The call to exit wont terminate all threads in a process and hence thread hangs here. This causes resouce leaks and other problems. It is seen only on linux 2.4.20.

For printing stacktrace it uses __builtin_return_address and __builtin_frame_address

The same program works fine on linux 2.6.26 kernel. It will exit the whole process when one of its thread dies as above.

Quoted 5 lines

Please let me know the patch details or any workaround, if any. This is a bit urgent, so please let me know for any pointers , if any

Thanks and Best Regards,
Pavan.

[Robert]
That doesn't seem surprising, the old LinuxThreads thread
implementation normally used with the 2.4 kernels was pretty poor. However it would likely be better to re-raise the signal rather than trying to exit out of the signal handler.

[Pavan]
Thanks Robert.
using exit(-1) instead of exit(0) does terminate all the threads in the process in my sample program. Please suggest if this workaround is safe for now.

I would like to kill whole process(and its threads) when one of the thread gets SIGSEGV signal. Could you please eloborate , how could i achieve the same by raising SIGSEGV signal again..

Best Regards,
Pavan.