Question: are initialized pthread_mutex_t objects kernel persistent? -- concern is for Linux V 2.6 onward.
Motivation:
If persistent: the objects resources will not be released with specific cleanup, pthread_mutex_destroy
In practical coding terms this means the mutex object will persist after the
creating program exits or aborts without cleanup, unless pthread_mutex_destroy
is called. I have code which is routinely removed by a nasty control program,
that employs kill -9, SIGKILL, after trying kill -15 (SIGTERM). The design
of the program is not going to change, it is vendor code. There is no way to
alter its base behavior. Correctly cleaning up the code often takes longer than the
control daemon likes, so 'zap' goes the process. This occurs frequently.
https://www.kernel.org/doc/Documentation/mutex-design.txt From Ingo Molnar
[ this is older material which says 'yes', spinlocks are a kernel mode object ]
'struct mutex' is the new mutex type, defined in include/linux/mutex.h and implemented in kernel/locking/mutex.c. It is a counter-based mutex with a spinlock and a wait-list. The counter has 3 states: 1 for "unlocked", 0 for "locked" and negative numbers (usually -1) for "locked, potential waiters queued".
http://man7.org/linux/man-pages/man2/execve.2.html has:
- All threads other than the calling thread are destroyed during an execve(). Mutexes, condition variables, and other pthreads objects are not preserved.
So calling one of the exec(), family is not a way to determine persistence.
http://man7.org/linux/man-pages/man3/exit.3.html has nothing about mutexes one way or the other.
Can someone point me to definitive code or documentation one way or the other? I need to confront our vendor with something solid.