bart | 81de224 | 2009-03-13 17:32:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Test program that locks and unlocks a process-shared mutex. |
| 3 | * See also https://bugs.kde.org/show_bug.cgi?id=187048. |
| 4 | */ |
| 5 | |
| 6 | |
| 7 | #define _GNU_SOURCE |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <pthread.h> |
| 11 | |
| 12 | |
| 13 | int main() |
| 14 | { |
| 15 | pthread_mutex_t mutex; |
| 16 | pthread_mutexattr_t attr; |
| 17 | |
| 18 | pthread_mutexattr_init(&attr); |
| 19 | pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); |
| 20 | pthread_mutex_init(&mutex, &attr); |
| 21 | pthread_mutexattr_destroy(&attr); |
| 22 | |
| 23 | pthread_mutex_lock(&mutex); |
| 24 | pthread_mutex_unlock(&mutex); |
| 25 | pthread_mutex_destroy(&mutex); |
| 26 | |
| 27 | fprintf(stderr, "Finished.\n"); |
| 28 | |
| 29 | return 0; |
| 30 | } |