Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.12 - Update to 3rd Edition #62

Open
WP-LKL opened this issue Dec 10, 2020 · 0 comments
Open

8.12 - Update to 3rd Edition #62

WP-LKL opened this issue Dec 10, 2020 · 0 comments

Comments

@WP-LKL
Copy link

WP-LKL commented Dec 10, 2020

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 WP-LKL changed the title 8.12 8.12 - Update to 3rd Edition Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant