in reply to forking patience...

NO way to know without the code, but since you say 'fork' in the title, my guess is that you are failing to exit; in the child processes. Without this, all the proccess complete from where the fork happened executing all the rest of the porgram, hence 'command 5' happens more than you expect.

The fact that I've made that mistake, oh, 10 or 15 times, also leads me to that suspicion.

--Bob Niederman, http://bob-n.com

Replies are listed 'Best First'.
Re: Re: forking patience...
by Anonymous Monk on Jun 20, 2003 at 14:50 UTC
    Many apologies in advance for the obfuscation...
    #!/opt/local/bin/perl -w open(STDERR, ">errors.log") || die "cannot create error log"; $dir = `pwd`; chomp $dir; if ($dir =~ m/(^.*)(GQ.*)/) { $path = $1; $lib = $2; }; chop $path; $xpath = "$path/ProjectSpecificInfo/"; print "working from $dir\n"; print "library is $lib\n"; opendir (DIR, ".") || die "cannot read from current dir"; open (XREF, "<$xpath$lib.OUT") || die "cannot open cross-ref file $xpa +th$lib.OUT"; %XREF = (); while (<XREF>) { ($SeqID, $MNid) = (split /\t/, $_)[0,1]; $XREF{$SeqID} = $MNid; }; `phred -pd phd_dir *.gz`; `phran -q $phran_cut phd_dir/*.phd.1`; `mv $dir/phd_dir/*.raw $dir/phd_dir/phran_dir/`; print "raw files moved to phran, now sorting\n"; while ($sequence = readdir (DIR)) { if ( $sequence =~ /MN/ ) { if ( $sequence =~ /(^.*)(\.gz)/ ) { $sequence = $1; }; if (exists $XREF{$sequence}) { $seqID = $XREF{$sequence}; if ($seqID =~ TB) { `mv $dir/phd_dir/phran_dir/$sequence.raw $dir/phd_dir/phra +n_dir/3prime/`; } else { `mv $dir/phd_dir/phran_dir/$sequence.raw $dir/phd_dir/phra +n_dir/5prime/`; }; }; }; }; $threeprimedir = "$dir/phd_dir/phran_dir/3prime"; $fiveprimedir = "$dir/phd_dir/phran_dir/5prime"; @primes = ($threeprimedir, $fiveprimedir); foreach $vfdir ( @primes ) { $pid = fork and next; &VF4($line); print "Completed $dir\n"; }; print "processing complete for $dir\n"; $dir/phd_dir/phran_dir/vf_dir/`; sub finish { chdir "$dir/phd_dir/phran_dir/vf_dir/"; print "Running artifact filter\n"; `af *.seq > afresults.log`; `mv *qc $dir/phd_dir/phran_dir/vf_dir/af_dir/`; `mv afresults.log $dir/phd_dir/phran_dir/vf_dir/af_dir/`; `mv *.af.out $dir/phd_dir/phran_dir/vf_dir/af_dir/`; `mv $dir/phd_dir/phran_dir/vf_dir/*.raw $dir/phd_dir/phran_d +ir/`; }; sub VF4($) { if ($vfdir =~ /3prime/) { chdir "$dir/phd_dir/phran_dir/3prime"; `gstVF4 -o $vffile3 *.raw > 3primevf.log`; print "finished Running VF4 in 3prime\n"; `mv $dir/phd_dir/phran_dir/3prime/* $dir/phd_dir/phran_dir/vf_dir/ +`; chdir ".."; `rm $vfdir`; #&finish; }elsif ($vfdir =~ /5prime/) { chdir "$dir/phd_dir/phran_dir/5prime"; `gstVF4 -o $vffile5 *.raw > 5primevf.log`; print "finished Running VF4 in 5prime\n"; `mv $dir/phd_dir/phran_dir/5prime/* $dir/phd_dir/phran_dir/vf_dir/ +`; chdir ".."; `rm $vfdir`; #&finish; }; &finish; };