Skip to content

Commit 7a56dda

Browse files
committed
switch-to-configuration-ng: don't block when the lockfile is already locked
When the lockfile is already locked, stc-ng currently blocks without any message indicating what is going on. This is very confusing to users, especially because most will not know about the lockfile. Since the current call blocks, we actually never end up in the else branch. Switching to a non-blocking call, makes sure that we print out an error and exit in case the lockfile is already locked by another process, which makes it a lot clearer what's going on and gives the user a clue as to what to do to unblock the situation.
1 parent 4cf8a14 commit 7a56dda

File tree

1 file changed

+1
-1
lines changed
  • pkgs/by-name/sw/switch-to-configuration-ng/src/src

1 file changed

+1
-1
lines changed

pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ fn do_system_switch(action: Action) -> anyhow::Result<()> {
10371037
die();
10381038
};
10391039

1040-
let Ok(_lock) = Flock::lock(lock, FlockArg::LockExclusive) else {
1040+
let Ok(_lock) = Flock::lock(lock, FlockArg::LockExclusiveNonblock) else {
10411041
eprintln!("Could not acquire lock");
10421042
die();
10431043
};

0 commit comments

Comments
 (0)