Learn and use fork(), vfork(), wait() and exec() system calls across Linux Systems

2 Responses

  1. Bogus Honcho says:

    I tried your first example in a virtual terminal in Linux Mint 19 XFCE, and it produced an error:

    l_fork.c:3:1: error: unknown type name ‘Int’; did you mean ‘int’?
    Int main(void)

    I corrected the ‘Int’ to ‘int’ and ran it again, and this time it produced a slightly different output to yours:

    Before fork
    after fork
    after fork

    Why does it produce two ‘after fork’ lines?

  2. Prashant Nandkar says:

    Fork() creates a child process that is why it prints two times, one for the parent and other for the child.
    As you can see there is fork() call before the “after fork” print statement.

Leave a Reply

Your email address will not be published. Required fields are marked *