1
0
UAHCode/CPE435/Lab1/demo_2.cpp

18 lines
330 B
C++
Raw Normal View History

2022-08-28 21:12:16 +00:00
/* This program illustrates the use of fork */
#include <stdio.h>
#include <iostream>
#include <unistd.h>
using namespace std;
int main()
{
int x;
x = 0;
fork();
x++;
// This should be printed twice, once by the parent and once by the child
cout << "I am process "<< getpid() << " and my x is " << x << endl;
return 0;
}