Revision 993
Free's shared memory in the core file upon error in forking or error in attaching to shared memory
libsim.c | ||
---|---|---|
6 | 6 |
#include <stdlib.h> |
7 | 7 |
#include <sys/shm.h> |
8 | 8 |
#include <sys/ipc.h> |
9 |
//#include <robot_shared.h>
|
|
9 |
#include <robot_shared.h> |
|
10 | 10 |
#include <string.h> |
11 | 11 |
|
12 | 12 |
|
13 |
//RobotShared* shared_state;
|
|
13 |
RobotShared* shared_state; |
|
14 | 14 |
|
15 | 15 |
void *tick(int sig) |
16 | 16 |
{ |
17 |
printf("robot process paused. suspending\n"); |
|
17 |
printf("robot process paused. suspending\n");
|
|
18 | 18 |
|
19 |
//shared_state->motor1++; |
|
20 |
|
|
21 | 19 |
if(raise(SIGTSTP)<0) |
22 | 20 |
printf("could not kill self!\n"); |
23 | 21 |
|
... | ... | |
32 | 30 |
struct itimerval iv; |
33 | 31 |
int ret; |
34 | 32 |
|
35 |
/*shared_state = shmat(atoi(envp[0]), NULL, 0);
|
|
33 |
shared_state = shmat(atoi(envp[0]), NULL, 0); |
|
36 | 34 |
if(shared_state < 0) |
37 | 35 |
{ |
38 | 36 |
printf("unable to get shared memory region\n"); |
39 | 37 |
return 1; |
40 |
}*/
|
|
38 |
}
|
|
41 | 39 |
|
42 | 40 |
|
43 | 41 |
printf("hello. I am a robot w/ memory_id %s\n", getenv("memory_id")); |
Also available in: Unified diff