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.
This commit is contained in:
r-vdp
2025-02-17 12:06:27 +01:00
parent 4cf8a147dd
commit 7a56ddaf9d
@@ -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();
};