blob: 028610f0125159f1eade18352d22a577686dee7a (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include "shm.h"
int main(void)
{
struct share_data *data;
int rv;
data = get_share();
if (!data)
return 1;
rv = pthread_mutex_lock(&data->m);
if (rv != 0) {
if (rv == EOWNERDEAD) {
printf("send (%d): recover mutex\n", getpid());
data->msg[0] = 0;
pthread_mutex_consistent(&data->m);
} else {
/* maybe rv == ENOTRECOVERABLE */
return 1;
}
}
printf("send (%d): type message and hit RETURN to send signal\n",
getpid());
fgets(data->msg, sizeof(data->msg), stdin);
/* set "sending" uprobe here */
pthread_cond_signal(&data->c);
pthread_mutex_unlock(&data->m);
sleep(1);
return 0;
}
|