Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

mr_p's scratchpad

by mr_p (Scribe)
on Oct 06, 2009 at 13:56 UTC ( #799484=scratchpad: print w/replies, xml ) Need Help??

Program Description:

The program forks a three Childern. The first one forks acts as Parent to the next two forked.

The problem I am having is, I keep getting the blow error

Can't use an undefined value as an ARRAY reference at /nss/nfx/shmem/lib/lib/perl5/site_perl//5.8.5/IPC/ line 446.

Thanks. Any help would be really appreciated.

#! /usr/bin/perl -w use strict; use lib "/nss/nfx/shmem/lib/lib"; use lib "/nss/nfx/shmem/lib/lib64"; use lib "/nss/nfx/shmem/lib/lib/perl5/site_perl/"; use File::Basename; use Getopt::Long; use File::Copy; use strict; #use IPC::Shareable; use IPC::Shareable qw(); my $child; my $serv_id; my $maxRcvrCount; my $stripeInstance; my $maxStripeInstance; my $user; my @ftpDirectoryListing=(); my @deDuppedArray=(); my @filesDownloaded=(); my $glue = 'data'; my %options = ( create => 1, exclusive => 0, mode => 0644, destroy => 1, ); my $deDuppedArrayHandle = tie @deDuppedArray, 'IPC::Shareable', 'data' +, \%options; my $filesDownloadedHandle = tie @filesDownloaded, 'IPC::Shareable', 'k +ala', \%options; sub pollDaemonParent { my $user = $_[0]; my @previousListing=(); my @currentListing=(); while (1) { @previousListing = @currentListing; @currentListing = getListing($user); $deDuppedArrayHandle->shlock(); @deDuppedArray = deDupArray1(\@previousListing, \@currentListi +ng); print "Parent: currentListing: @currentListing deDuppedArra +y: @deDuppedArray\n"; $deDuppedArrayHandle->shunlock(); deleteRemoteFiles1(); select (undef, undef, undef,.5); } } sub deleteRemoteFiles1 { # TODO: Get list and delete from server. once deleted $filesDownloadedHandle->shlock(); if ($#filesDownloaded >= 0) { print "\nParent: deleteListing: @filesDownloaded\n"; } foreach (@filesDownloaded) { deleteFile($_); } @filesDownloaded=(); $filesDownloadedHandle->shunlock(); } sub pollDaemonChild { my $user = $_[0]; print "ChildStarted: $stripeInstance\n"; while (1) { @ftpDirectoryListing = (); $deDuppedArrayHandle->shlock(); @ftpDirectoryListing = @deDuppedArray; $deDuppedArrayHandle->shunlock(); if ($#ftpDirectoryListing >= 0) { print "Child - @ftpDirectoryListing: @ftpDirectoryListing\ +n"; } select (undef, undef, undef,1); } } sub getListing { my @ftpListing1 = (); push (@ftpListing1, "abc.xml"); push (@ftpListing1, "xyz.xml"); return @ftpListing1; } sub deDupArray1 { my @difference = ("dedup1.xml", "dedup2.xml"); return @difference; } sub addToDeleteList { $|++; $filesDownloadedHandle->shlock(); push (@filesDownloaded, "$_[0]"); $filesDownloadedHandle->shunlock(); } # main { $user = "IAmUser"; $serv_id = "1"; $maxRcvrCount = "5"; $stripeInstance = "1" ; $maxStripeInstance = "3"; $SIG{'ALRM'} = 'sig_alrm'; my $startingInstanceNum=1; my @kids; for (1 .. $maxStripeInstance) { $stripeInstance = $startingInstanceNum; print "stripeInstance: $startingInstanceNum\n"; unless ($child = fork) { # i'm the child die "cannot fork: $!" unless defined $child; if($stripeInstance == 1 ) { pollDaemonParent($user); } else { pollDaemonChild($user); } exit; } push @kids, $child; # in case we care about their pids $startingInstanceNum++; } while (1) { sleep 1; }
Log In?

What's my password?
Create A New User
LanX Everybody quotes it, some people read it, and a few people go by it
[ambrus]: LanX: why would I read it? isn't it a book for managers? I don't want to be a manager.
[ambrus]: I don't quote it either.
[erix]: it's really a software book, albeit about experiences from the 60s-80s. People haven't changed all that much though.
[erix]: a software project book, is probably more exact
[ambrus]: Yes, but I'm not managing software teams either.
[ambrus]: I'm not only not a restaurant manager, but also not a software manager.
[erix]: Peter's principle says it' sonly a matter of time ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-09-22 13:57 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (264 votes). Check out past polls.