Skip to content

Instantly share code, notes, and snippets.

@hone
Created October 30, 2009 17:46
Show Gist options
  • Select an option

  • Save hone/222575 to your computer and use it in GitHub Desktop.

Select an option

Save hone/222575 to your computer and use it in GitHub Desktop.
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
using namespace std;
main()
{
int x = 6;
int pid = fork();
if (pid > 0)
{
x = 200;
cout << "parent" << "x = " << x << " " << &x << endl;
sleep(100);
}
else
{
sleep(10);
cout << "child" << "x = " << x << " " << &x << endl;
sleep(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment