Re: Clarification of pthread_cleanup_push() needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Richard Weinberger:

> Well, this manpage does not talk much about the cleanup routine, except for
> "Consequently, clean-up handlers cease to be useful", which is clear as mud.

I think this refers to the fact that pthread_cleanup_push and
pthread_cleanup_pop are not necessarily async-cancel-safe.

> Back to the cleanup routine, with asynchronous cancellation:
> - it must not use any function which might got interrupted by cancel,
> - it may only use async-signal-safe function, except long jumps.
>
> Is this correct?

I think there are no restrictions on the cleanup handler *contents*
due to asynchronous cancellation.  The restrictions are on the code
that is interrupted.

You need to find a way to safely register them.  Code compiled by GCC
with -fexceptions and -fasynchronous-unwind-tables should work,
though.  In that case, the cleanup handler is not explicitly
registered, but implicitly identified by the region of code within
which the program counter is located during asynchronous cancellation.

> To give you some background, I'm porting an application to NPTL
> which comes from an operating system where cancelling threads and
> automatic cleanup is the way to go.

Do you have a list of functions that need to be async-cancel-safe for
this purpose?



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux