-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIpcMutex.cpp
More file actions
28 lines (23 loc) · 945 Bytes
/
IpcMutex.cpp
File metadata and controls
28 lines (23 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* \file IpcMutex.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
int err {};
pthread_mutexattr_t attr {};
err = pthread_mutexattr_init(&attr); if (err) return err;
err = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); if (err) return err;
pthread_mutex_t shm_mutex {};
err = pthread_mutex_init(&shm_mutex, &attr); if (err) return err;
err = pthread_mutexattr_destroy(&attr); if (err) return err;
err = pthread_mutex_lock(&shm_mutex); if (err) return err;
err = pthread_mutex_unlock(&shm_mutex); if (err) return err;
err = pthread_mutex_destroy(&shm_mutex); if (err) return err;
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------