diff options
Diffstat (limited to 'semestr-5/so/lista1/so21_lista_1/fileref.c')
-rw-r--r-- | semestr-5/so/lista1/so21_lista_1/fileref.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/semestr-5/so/lista1/so21_lista_1/fileref.c b/semestr-5/so/lista1/so21_lista_1/fileref.c index b5d6f9f..8ea7aad 100644 --- a/semestr-5/so/lista1/so21_lista_1/fileref.c +++ b/semestr-5/so/lista1/so21_lista_1/fileref.c @@ -32,7 +32,16 @@ static void do_read(int fd) { static void do_close(int fd) { /* TODO: In the child close file descriptor, in the parent wait for child to * die and check if the file descriptor is still accessible. */ - + int pid = fork(); + if (pid > 0) { + printf("[%d] %d\n", getpid(), fcntl(fd, F_GETFD)); + close(fd); + printf("[%d] %d\n", getpid(), fcntl(fd, F_GETFD)); + } + else { + wait(NULL); + printf("[%d] %d\n", getpid(), fcntl(fd, F_GETFD)); + } exit(0); } |