+
+ # Check if a lockfile already exists.
+ if (-e "$Pakfire::lockfile") {
+ &Pakfire::message("PAKFIRE ERROR: Another instance of pakfire is already running!");
+ exit 1;
+ }
+
+ # Write lockfile.
+ open(LOCK, ">$Pakfire::lockfile");
+
+ # Pakfire has locked in this session set locket to "1".
+ $locked = "1";
+
+ # Close filehandle.
+ close(LOCK);
+