CSAPP-3e-Solutions icon indicating copy to clipboard operation
CSAPP-3e-Solutions copied to clipboard

8.12 - Update to 3rd Edition

Open WP-LKL opened this issue 3 years ago • 0 comments

The following code from the .pdf version:

#include <stdio.h>  
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h> 


void try() 
{
    fork();
    printf("Example\n");
    fork();
    return;
}

int main() 
{
    try(); fork();
    printf("Example\n");
    exit(0);
}

Try: https://www.programiz.com/c-programming/online-compiler/

Generates 10 lines of "example" the same when I hand ran it. (not the 8 suggested here: https://github.com/DreamAndDead/CSAPP-3e-Solutions/blob/master/chapter8/8.12.md)

solution: 1 * fork -> 2 * "example\n" + 2 * fork -> 4 * fork -> 8 * "example\n". = 10 * "example\n"

It seems that the solutions are from the 2nd edition and not the 3rd.

WP-LKL avatar Dec 10 '20 16:12 WP-LKL