Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ex1/ex1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
18 changes: 16 additions & 2 deletions ex2/ex2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}