aboutsummaryrefslogtreecommitdiff
path: root/semestr-5/so/lista1
diff options
context:
space:
mode:
Diffstat (limited to 'semestr-5/so/lista1')
-rw-r--r--semestr-5/so/lista1/rozwiazania/zad3.c10
-rw-r--r--semestr-5/so/lista1/so21_lista_1/fileref.c11
-rw-r--r--semestr-5/so/lista1/so21_lista_1/test.c6
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;
+ }
+}