[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20010821: Gempak, Perl, and Gemplt errors



Hi there Steve,

I sent it too fast.  There there were two bugs in the version I sent you.  Here's the fixed version:
################################################
#!/usr/local/bin/perl

#[previous stuff]

#setup process lock
$lockdir = "/home/hokukea/rknabb/gempak/gemlock";
$pid = $$;
$gemlock=".inuse.$pid";
$PROCLOCK=">$lockdir/$gemlock";
open(PROCLOCK);
close(PROCLOCK);
$count = 0;
opendir DIRECTORY, $lockdir;
@filelist = grep { /^\.inuse/ && -f "$lockdir/$_" } readdir DIRECTORY;
@filelist = sort(@filelist);
closedir DIRECTORY;
while (("$filelist[0]" ne "$gemlock") && ($count < 120)) {
  sleep 1;
  if($count > 60) {
    unlink("$lockdir/$gemlock");
    die;
  }
  opendir DIRECTORY, $lockdir;
  @filelist = grep { /^\.inuse/ && -f"$lockdir/$_"} readdir DIRECTORY;
  closedir DIRECTORY;
  @filelist=sort(@filelist);
  $count++;
}

#gempak program goes here!

#clear process lock
unlink("$lockdir/$gemlock");
#################################################

You mentioned a problem with starting gempak programs via the cron.  If I am understanding this correctly, the way we use gempak through crons is okay with the above work around.  I mentioned what I do in the previous email, but to clarify:  we have the cron set up to call csh scripts.  These csh scripts then call perl scripts which then call the gempak programs.  So when the perl scripts are forked from the csh scripts, they get their own unique PID.  So each instance of a script called by a csh script should always have a unique PID from all other processes on the system.  Am I correct?  It seems to be this way.

Thank you very much for giving me the answer such a looong time ago.  My script does basically what your csh script does.  It probably takes a bit longer but at least it works.

Since everything is working on my end, reply to this at your leisure.  Thanks!

Sincerely,
Sean Daida
address@hidden