diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-11-13 17:32:03 +0100 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-11-13 17:32:03 +0100 |
commit | ff0ac5bf2b3069200d2bb5a56bc3eef0b4bcb44a (patch) | |
tree | 6778fd6eb8fb48cff51564d4110ed3bd168a3b2e /semestr-5/so/lista1 | |
parent | fa505e1e8d7f990d608144ccd97e9f960c6b8b57 (diff) |
update
Diffstat (limited to 'semestr-5/so/lista1')
-rw-r--r-- | semestr-5/so/lista1/rozwiazania/zad3.c | 10 | ||||
-rw-r--r-- | semestr-5/so/lista1/so21_lista_1/fileref.c | 11 | ||||
-rw-r--r-- | semestr-5/so/lista1/so21_lista_1/test.c | 6 |
3 files changed, 26 insertions, 1 deletions
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<unistd.h> + +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; + } +} |