######Semaphore implementation ##### use IPC::Semaphore sub IPC_PRIVATE {0}; sub IPC_RMID {10}; sub IPC_CREAT {0001000}; sub GETVAL {5}; sub semwait { my $sem=shift; semop($sem, pack("s3", 0, -1, 0)) || die "semw: $!\n"; } sub semsign { my $sem=shift; semop($sem, pack("s3", 0, +1, 0)) || die "sems: $!\n"; } my $sem=semget(&IPC_PRIVATE, 1, &IPC_CREAT | 0666) || die "semget: $!\n"; warn "semid= $sem\n"; semsign($sem); ####### Pipes implementation ######## use IO::Handle; pipe(PARENT_READ, PARENT_WRITE); PARENT_WRITE->autoflush(1); #### In the child process ##### { semwait($sem); print PARENT_WRITE "PID : Pid of the process is $$ \n" ; print PARENT_WRITE "SIGNAL : Signal sent from the process \n"; semsign($sem); } ##### In the parent ##### { while ( $msg = && $signal_received < $total_signals ) { if($msg =~ /PID/) { chomp($msg); my @fields = split (/ /,$msg); print "Child with fields @fields has communicated to me \n"; ##### This print statement is not printing anything either on the console or even if I redirect it to a file } } }