pthread_mutexattr_setrobust.3: ffix

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2020-12-20 11:58:53 +01:00
parent 7f3c0a5fcb
commit 6a5f3c599c
1 changed files with 11 additions and 11 deletions

View File

@ -202,10 +202,10 @@ The following shell session shows what we see when running this program:
$ \fB./a.out\fP
[original owner] Setting lock...
[original owner] Locked. Now exiting without unlocking.
[main thread] Attempting to lock the robust mutex.
[main thread] pthread_mutex_lock() returned EOWNERDEAD
[main thread] Now make the mutex consistent
[main thread] Mutex is now consistent; unlocking
[main] Attempting to lock the robust mutex.
[main] pthread_mutex_lock() returned EOWNERDEAD
[main] Now make the mutex consistent
[main] Mutex is now consistent; unlocking
.EE
.in
.SS Program source
@ -217,7 +217,7 @@ $ \fB./a.out\fP
#include <errno.h>
#define handle_error_en(en, msg) \e
do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
static pthread_mutex_t mtx;
@ -250,25 +250,25 @@ main(int argc, char *argv[])
/* "original_owner_thread" should have exited by now */
printf("[main thread] Attempting to lock the robust mutex.\en");
printf("[main] Attempting to lock the robust mutex.\en");
s = pthread_mutex_lock(&mtx);
if (s == EOWNERDEAD) {
printf("[main thread] pthread_mutex_lock() returned EOWNERDEAD\en");
printf("[main thread] Now make the mutex consistent\en");
printf("[main] pthread_mutex_lock() returned EOWNERDEAD\en");
printf("[main] Now make the mutex consistent\en");
s = pthread_mutex_consistent(&mtx);
if (s != 0)
handle_error_en(s, "pthread_mutex_consistent");
printf("[main thread] Mutex is now consistent; unlocking\en");
printf("[main] Mutex is now consistent; unlocking\en");
s = pthread_mutex_unlock(&mtx);
if (s != 0)
handle_error_en(s, "pthread_mutex_unlock");
exit(EXIT_SUCCESS);
} else if (s == 0) {
printf("[main thread] pthread_mutex_lock() unexpectedly succeeded\en");
printf("[main] pthread_mutex_lock() unexpectedly succeeded\en");
exit(EXIT_FAILURE);
} else {
printf("[main thread] pthread_mutex_lock() unexpectedly failed\en");
printf("[main] pthread_mutex_lock() unexpectedly failed\en");
handle_error_en(s, "pthread_mutex_lock");
}
}