this is my sample program but it work as flag does not affect in child process and even sem_wait , sem_trywait also wont work, apart from signals and fcntl is there any other way to wait till particular event triggered.
#include "header.h"
void main()
{
int flag = 1;
pid_t cpid;
sem_t semobj;
int value;
cpid = fork() ;
sem_init ( &semobj, 0, 2);
if ( cpid == 0)
{
printf ("Chile Process id = %d, PPID= %d\n",getpid(),getppid());
while ( FLAG ); // here i need to wait until parent process disables the flag
//sem_trywait ( &semobj);
//sem_getvalue ( &semobj, &value );
printf ( "After Wait =%d\n", FLAG );
sleep(10);
}
else
{
printf( "Parent Process id =%d\n",getpid() );
sleep(3);
printf( "Setting Flag value\n" );
FLAG = 0; // here i need to set a flag
sleep(7);
}
}