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

37 lines
481 B
Plaintext
Raw Normal View History

2000-04-05 10:09:46 -05:00
#!/usr/local/bin/perl -w
use Fcntl ':flock'; # import LOCK_* constants
$res=flock("/tmp/my.lock", LOCK_EX);
print $res;
system ("ls -alrt /tmp");
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();