From 7a56ddaf9d42e9aee8ddbf2d95f9ea82502d094c Mon Sep 17 00:00:00 2001 From: r-vdp Date: Mon, 17 Feb 2025 12:06:27 +0100 Subject: [PATCH] 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. --- pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs index a64d8566225b..64fc71e85aed 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs @@ -1037,7 +1037,7 @@ fn do_system_switch(action: Action) -> anyhow::Result<()> { die(); }; - let Ok(_lock) = Flock::lock(lock, FlockArg::LockExclusive) else { + let Ok(_lock) = Flock::lock(lock, FlockArg::LockExclusiveNonblock) else { eprintln!("Could not acquire lock"); die(); };