From 742115e892a72139d1c4d1cbad845e71672b9fce Mon Sep 17 00:00:00 2001 From: Artem Chuvashov Date: Tue, 24 Dec 2024 21:50:47 +0700 Subject: [PATCH] made lab9 --- 23213/a.chuvashov/lab9/lab9.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 23213/a.chuvashov/lab9/lab9.c diff --git a/23213/a.chuvashov/lab9/lab9.c b/23213/a.chuvashov/lab9/lab9.c new file mode 100644 index 00000000..549772ff --- /dev/null +++ b/23213/a.chuvashov/lab9/lab9.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +int main(int argc, char** argv) { + if (argc != 2) { + fprintf(stderr, "Wrong amount of arguments\n"); + return -1; + } + + pid_t pid; + if ((pid = fork()) > 0) { + wait(NULL); + printf("This is parent process\n"); + } else if (pid == 0) { + execl("cat", "cat", argv[1], NULL); + perror("Couldn`t exec"); + return -1; + + } else { + perror("Couldn`t fork"); + return -1; + } + return 0; +}