Here are two program that is opening the two file in the two different process in two different window. Both the process are communicating with each other. Signal concept is used, with pause() signal. Both programs are accessing the same file and interchanging the Process ID. For executing this program, in a directory save these two program with ".c" extension. Along with it make a file name "test.txt" by writing following commands.
# or $(*already present) cat > test.txt
(then press ctrl+D).
this will create empty file with name test of extension txt.(text).
********************************************************************************
/* Program 1
process1.c */
/* Program to generate the process ID and write it on file and communicate with other process*/
/* Programmer : Raj Prajapati */
#include<stdio.h>
#include<fcntl.h>
#include<signal.h>
const int buff=100;
void abc();
int main()
{
int pid,fd,pid2,i;
char data[100];
fd=open("test.txt",O_RDWR,0777);
printf("\n Process 1 Running ");
# or $(*already present) cat > test.txt
(then press ctrl+D).
this will create empty file with name test of extension txt.(text).
********************************************************************************
/* Program 1
process1.c */
/* Program to generate the process ID and write it on file and communicate with other process*/
/* Programmer : Raj Prajapati */
#include<stdio.h>
#include<fcntl.h>
#include<signal.h>
const int buff=100;
void abc();
int main()
{
int pid,fd,pid2,i;
char data[100];
fd=open("test.txt",O_RDWR,0777);
printf("\n Process 1 Running ");