From ff0ac5bf2b3069200d2bb5a56bc3eef0b4bcb44a Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Sat, 13 Nov 2021 17:32:03 +0100 Subject: update --- semestr-5/so/lista1/rozwiazania/zad3.c | 10 ++++++++++ semestr-5/so/lista1/so21_lista_1/fileref.c | 11 ++++++++++- semestr-5/so/lista1/so21_lista_1/test.c | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 semestr-5/so/lista1/rozwiazania/zad3.c create mode 100644 semestr-5/so/lista1/so21_lista_1/test.c (limited to 'semestr-5/so/lista1') diff --git a/semestr-5/so/lista1/rozwiazania/zad3.c b/semestr-5/so/lista1/rozwiazania/zad3.c new file mode 100644 index 0000000..c575be8 --- /dev/null +++ b/semestr-5/so/lista1/rozwiazania/zad3.c @@ -0,0 +1,10 @@ +#include + +const char *t[2]; + +int main() { + t[0] = "siemandero"; + t[1] = NULL; + + execvp("python", t); +} 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); } diff --git a/semestr-5/so/lista1/so21_lista_1/test.c b/semestr-5/so/lista1/so21_lista_1/test.c new file mode 100644 index 0000000..07e9711 --- /dev/null +++ b/semestr-5/so/lista1/so21_lista_1/test.c @@ -0,0 +1,6 @@ +int main() { + int x = 0; + while (1) { + x += 1; + } +} -- cgit v1.2.3