f684b17b45029a3607a77f7a37d93d0811d11feb
8 if (fork()) //il s'agit du père
11 if (lockf(fd
, F_LOCK
, 1) < 0) {
12 write(fd
, "pere lockf failed\n", 18);
15 for (i
= 0; i
< 5; i
++) {
16 write(fd
, "pere ecrit\n", 12);
19 write(fd
, "pere va liberer le verrou\n", 26);
21 lockf(fd
, F_ULOCK
, 0);
23 } else { //il s'agit du fils
24 lseek(fd
, 0, 0); //verrouillé l'octet 0
25 if (lockf(fd
, F_LOCK
, 1) < 0) {
26 write(fd
, "fils lockf failed\n", 18);
29 for (i
= 0; i
< 4; i
++) {
30 write(fd
, "fils ecrit\n", 12);
33 write(fd
, "fils va liberer le verrou\n", 26);
35 lockf(fd
, F_ULOCK
, 0);