Skip to content

Commit

Permalink
Merge pull request #3541 from rjbou/lock
Browse files Browse the repository at this point in the history
Locked state and signals, avoid
  • Loading branch information
AltGr committed Mar 12, 2019
2 parents 03d6870 + 6b2eb9c commit 2dd020c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/opamSystem.ml
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,18 @@ let rec flock_update
Unix.(lockf fd F_ULOCK 0);
Unix.lockf fd (unix_lock_op ~dontblock:true flag) 0
with Unix.Unix_error (Unix.EAGAIN,_,_) ->
if dontblock then raise Locked;
if dontblock then
OpamConsole.error_and_exit `Locked
"Another process has locked %s and non blocking mode enabled"
file;
OpamConsole.formatted_msg
"Another process has locked %s, waiting (%s to abort)... "
file (if Sys.win32 then "CTRL+C" else "C-c");
(try Unix.lockf fd (unix_lock_op ~dontblock:false flag) 0;
with Sys.Break as e -> OpamConsole.msg "\n"; raise e);
let rec lock_w_ignore_sig () =
try Unix.lockf fd (unix_lock_op ~dontblock:false flag) 0;
with Sys.Break as e -> (OpamConsole.msg "\n"; raise e)
| Unix.Unix_error (Unix.EINTR,_,_) -> lock_w_ignore_sig ()
in lock_w_ignore_sig ();
OpamConsole.msg "lock acquired.\n");
lock.kind <- (flag :> lock_flag)
| _ -> assert false
Expand Down

0 comments on commit 2dd020c

Please sign in to comment.