alliance/dev/cvslargo/www/cgi-bin/czo/lock.cgi

37 lines
484 B
Plaintext
Raw Normal View History

2000-06-06 10:34:49 -05:00
#!/usr/bin/perl -w
2000-04-05 10:09:46 -05:00
use Fcntl ':flock'; # import LOCK_* constants
$res=flock("/tmp/my.lock", LOCK_EX);
2000-06-06 10:34:49 -05:00
print $res . "\n";
# system ("ls -alrt /tmp");
2000-04-05 10:09:46 -05:00
sleep 10;
exit 0
__END__
sub lock {
flock(MBOX,LOCK_EX);
# and, in case someone appended
# while we were waiting...
seek(MBOX, 0, 2);
}
sub unlock {
flock(MBOX,LOCK_UN);
}
open(MBOX, ">>/usr/spool/mail/$ENV{'USER'}")
or die "Can't open mailbox: $!";
lock();
print MBOX $msg,"\n\n";
unlock();