O#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;

int main(void)
{
	int k=3;
	int status;
	pid_t pid;
	pid=fork();
	//k=2;
	if (pid<0){
		cout << "Fork() error !" <<endl;
		_exit(1);

	}
	if (pid==0) {
		//child process
		k=2;
		cout << "Child process PID=" <<" "<< getpid()<<" "<<"Parent process PID="<< getppid() <<endl;
		sleep(10);
		cout << " Child k=" << k <<endl;
		_exit(-10);
	} else {
		//Parent process
		cout << "Parent process,"<<" " <<"PIDR="<< pid<< "PID=" << getpid() <<"Parent process PID=" << getppid() <<endl;
		cout<< "Parent k=" << k <<endl;
		pid=wait(&status);
		if (WIFEXITED(status)) {
		cout <<"Process PID= " << pid <<"finished with code: " <<(WEXITSTATUS(status))<<"from process with PID: "<<getpid()<<endl;
	}
	}
	return 0;
}


