+sub is_lock {
+ if ( -e "$ENV{'HOME'}/.antifraude/lock/antifraude.pid" ) {
+ # Lock file encontrado
+ return 1;
+ }
+ # No hay lock file!
+ return 0;
+}
+
+sub unlock {
+ unlink ("$ENV{'HOME'}/.antifraude/lock/antifraude.pid");
+}
+
+sub lock {
+ if (!is_lock()) {
+ local $lfile = "$ENV{'HOME'}/.antifraude/lock/antifraude.pid";
+ open(LOCKFILE,">>$lfile");
+ print LOCKFILE $$;
+ close(LOCKFILE);
+ return 1;
+ }
+ return 0;
+}
+