switch-to-configuration-ng: don't block when the lockfile is already locked (#382797)

This commit is contained in:
Ramses 2025-02-19 11:07:33 +01:00 committed by GitHub
commit 9abef1cee8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -95,7 +95,7 @@ if (!-f "/etc/NIXOS" && (read_file("/etc/os-release", err_mode => "quiet") // ""
make_path("/run/nixos", { mode => oct(755) });
open(my $stc_lock, '>>', '/run/nixos/switch-to-configuration.lock') or die "Could not open lock - $!";
flock($stc_lock, LOCK_EX) or die "Could not acquire lock - $!";
flock($stc_lock, LOCK_EX|LOCK_NB) or die "Could not acquire lock - $!";
openlog("nixos", "", LOG_USER);
# run pre-switch checks