Question: debugg hw 2 _ q 9 . c: In function 'main': hw 2 _ q 9 . c: 2 2 : 1 1 : warning:

debugg
hw2_q9.c: In function 'main':
hw2_q9.c:22:11: warning: missing terminating " character
22| printf ("Process %d failed to fork!
", getpid());
hw2_q9.c:22:11: error: missing terminating " character
22| printf ("Process %d failed to fork!
", getpid());
hw2_q9.c:23:3: error: expected expression before 'return'
23| return 1;
hw2_q9.c:23:12: error: expected 'i' before '
code:
//WaitChild.c
#include
#include
#include
int main()
{
pid_t pid;
int status;
pid = fork();
if (pid ==0)
{
printf ("I am process %d", getpid ());
printf (" and my parent is %d.
", getppid ());
}
else if (pid >0)
{
printf ("I am parent %d", getpid ());
printf (" and my child is %d.
", pid);
}
else
{
printf ("Process %d failed to fork!
, getpid());
return 1;
}
printf ("I am process %d.
", getpid());
if (pid ==0)
{
sleep (5); //sleep 5 seconds
printf ("I am process %d", getpid());
printf (" and I quit.
");
}
else
{
printf ("I am parent %d", getpid());
printf (" and I'm waiting for child %d.
", pid);
wait(&status);
printf ("I am parent %d", getpid());
printf (" and my child %d", pid);
printf (" has arrived. I quit too.
");
}
return 0;
}
 debugg hw2_q9.c: In function 'main': hw2_q9.c:22:11: warning: missing terminating " character

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!