-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnettoyer.c
executable file
·51 lines (40 loc) · 1008 Bytes
/
nettoyer.c
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
42
43
44
45
46
47
48
49
50
51
/**
* @file nettoyer.c
* @author godwin AMEGAH (komlan.godwin.amegah@gmail.com)
* @brief
* @version 0.1
* @date 2022-01-23
*
* @copyright Copyright (c) 2022
*
*/
#include "shm.h"
int main(int argc, char *argv[])
{
int a;
(void)argv;
a = ainit("debut du programme nettoyer");
ASSERT(a != -1, "ainit failed/nettoyer");
adebug(2, "### début programme");
if (argc >= 2)
{
fprintf(stderr, "usage: nettoyer : 1 arg\n");
exit(EXIT_FAILURE);
}
if (isMaShmOpen())
{
void *ma = attacher(); // appelle mmap ()
ASSERT(ma != MAP_FAILED, "mmap failed/main");
vaccinodrome_t *ctl = ma;
size_t tailleSegment = sizeof(vaccinodrome_t) + ctl->n * sizeof(siege_t) + ctl->m * sizeof(box_t);
// nettoyer les restes (semaphores...) d'un précedent vaccinodrome.
clean(ma);
//
detacher(ma, tailleSegment);
// supprimer la memoire partagée
supprimer();
// On a fini de nettoyer, on peut quitter ce programme !
adebug(2, "### fin programme");
}
return EXIT_SUCCESS;
}