fork
(successfully!). Modify the
diagram below, which shows the state of the kernel prior to
the fork, to show its state after the call
to fork, labeled "Point A" in the code below.
NOTE: in the diagram, a "?" simply refers to a location not
shown in thediagram.
int main()
{
int fd = -1;
pid_t t = fork();
← Point A
if (t == 0)
{
fd = open("tmp.txt",O_WRONLY|O_CREAT);
dup2(fd,1);
}
← Point B
return 0;
}
|
int main()
{
int fd = -1;
pid_t t = fork();
← Point A
if (t == 0)
{
fd = open("tmp.txt",O_WRONLY|O_CREAT);
dup2(fd,1);
}
← Point B
return 0;
}
|