diff --git a/23213/a.chuvashov/lab9/lab9.c b/23213/a.chuvashov/lab9/lab9.c new file mode 100644 index 00000000..f0297a38 --- /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", argv[1], NULL); + perror("Couldn`t exec"); + return -1; + + } else { + perror("Couldn`t fork"); + return -1; + } + return 0; +}