Thanks for all your replies. I should have mentioned that in my case child has been forked already and now I wish to communicate with specific. need Child to Child communication. kindly check the comment section below Suggestion for alternate approach is most welcome as well.

sub make_new_child { # Make new child... my $pid; my $sigset; # block signal for fork $sigset = POSIX::SigSet->new(SIGINT); sigprocmask(SIG_BLOCK, $sigset) or die "Can't block SIGINT for fork: $!\n"; die "fork: $!" unless defined ($pid = fork); if ($pid) { # Parent records the child's birth and returns. sigprocmask(SIG_UNBLOCK, $sigset) or die "Can't unblock SIGINT for fork: $!\n"; print "PID $pid\n" if $Debug; $children{$pid} = 1; $children++; return; } else { print "Child....\n" if $Debug; $SIG{INT} = 'DEFAULT'; # make SIGINT kill us as it did be +fore my $request = ""; # full long big request my $nreads = 0; # number of read loops my $tmout = 150; # timeout in second # unblock signals sigprocmask(SIG_UNBLOCK, $sigset) or die "Can't unblock SIGINT for fork: $!\n"; # handle connections until we've reached $MAX_CLIENTS_PER_CHIL +D for (my $i=0; $i < $MAX_CLIENTS_PER_CHILD; $i++) { # my $device=""; print "New connection....\n" if $Debug; my $client = $Socket->accept() or last; $client->autoflush(1); ($Debug && $client) ? print "Accepted....\n" : print "No S +ignal Recieved\n"; # do something with the connection my $sel = IO::Select->new($client); while ( $sel->can_read($tmout) ) { my $n = sysread($client, $request, 9999,length($re +quest)); last if ($n==0); $nreads++; my $display = ""; if ( $nreads == 0 ) { $display = '[timeout]'; } elsif ( length $request == 0 ) { $display = '[empty]'; } else { $display = $request; } $request=""; print "$display\n" if $Debug; my @data = split(/,/,$display); if($data[0] eq '!!'){ # A command #### ####Received the command here to send it t +o child PID 123 ###### child PID 123 has been already fork +ed and free ###### to serve this request print "A command, Lets send\n"; my $to_pid = $data[1]; my $command = $data[2];#__________________ +___________________________________________________ # # Lets send command to $to_pid from here #_________________________________________ +____________________________ # qx (echo e) print CHLD_IN "$command $pid sent from $p +id \n"; #print FHY ("OK, Lets Send coand\n"); sleep(3); } else { } } } exit(0); } }

In reply to Re: Child process inter communication by smarthacker67
in thread Child process inter communication by smarthacker67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.