Skip to content

Commit

Permalink
mkpidlock: close update loop in error path (JuliaLang#51902)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Oct 28, 2023
1 parent 0a0bd00 commit 9c581cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stdlib/FileWatching/src/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mutable struct LockMonitor
lock = new(at, fd, update)
finalizer(close, lock)
catch ex
update === nothing || close(update)
tryrmopenfile(at)
close(fd)
rethrow(ex)
Expand All @@ -100,10 +101,13 @@ end
function mkpidlock(at::String, proc::Process; kwopts...)
lock = mkpidlock(at, getpid(proc); kwopts...)
closer = @async begin
wait(proc)
close(lock)
try
wait(proc)
finally
close(lock)
end
end
isdefined(Base, :errormonitor) && Base.errormonitor(closer)
Base.errormonitor(closer)
return lock
end

Expand Down

0 comments on commit 9c581cd

Please sign in to comment.