*/
/* Help printing routine */
void usage(void);
+void HandSigInt(int sig);
#define MSGMAXSIZE 256
+char *shmname = "messages";
+char *semname = "messages";
int main(int argc, char *argv[])
{
int i;
sem_t * sem;
time_t t;
- char *shmname = "messages";
- char *semname = "messages";
char * res;
void * shm_ptr;
/*
printf("Wrong number of arguments %d\n", argc - optind);
usage();
}
+ Signal(SIGINT, HandSigInt);
// Get shared memory segment
- RemoveShm(shmname);
shm_ptr = CreateShm(shmname, MSGMAXSIZE, 0666, 0);
if ( shm_ptr == NULL) {
perror("Cannot find shared memory");
printf(" -s semname use semname semaphore\n");
exit(1);
}
+
+void HandSigInt(int sig)
+{
+ RemoveShm(shmname);
+ sem_unlink(semname);
+ exit(0);
+}