/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/wait.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> int main() { int pid; int fd; char buf[8192]; close(creat("TOTO", 0)); if (!(pid = fork())) { printf("p1 ecrit dans le fichier\n"); assert((fd = open("TOTO", O_WRONLY)) >= 0); while (1) assert(write(fd, buf, 8192) == 8192); } sleep(2); printf("p2 tue p1\n"); assert(kill(pid, SIGKILL) >= 0); assert(waitpid(pid, NULL, 00) >= 0); printf("p2 lit le fichier\n"); assert((fd = open("TOTO", O_RDONLY)) >= 0); assert(read(fd, buf, 8192) == 8192); printf("Test concluant, il n'y a pas eu de blocage.\n"); return EXIT_SUCCESS; }