diff --git a/ex1/ex1.c b/ex1/ex1.c index c4b111641..510eef9d2 100644 --- a/ex1/ex1.c +++ b/ex1/ex1.c @@ -10,5 +10,19 @@ int main(void) { // Your code here + pid_t pid = fork(); + + if (pid == 0) + { + int x = 200; + printf("\n This is the child, x = %d\n", x); + exit(1); + } + else + { + int x = 100; + printf("\n This is the parent, x = %d\n", x); + } + return 0; } diff --git a/ex2/ex2.c b/ex2/ex2.c index 4245375b9..abe638b9e 100644 --- a/ex2/ex2.c +++ b/ex2/ex2.c @@ -8,7 +8,21 @@ int main(void) { - // Your code here - + // Your code here + pid_t pid = fork(); + FILE *fp; + fp = fopen("text.txt", "w+"); + + if (pid == 0) + { + + fprintf(fp, "\n I\'m printing from the child\n"); + exit(1); + } + else + { + fprintf(fp, "\n I\'m printing from the parent\n"); + } + return 0; }