From: Sergey Matveev Date: Sun, 1 Oct 2023 06:57:23 +0000 (+0300) Subject: Lock file must stay opened till the very end of the program X-Git-Tag: v2.0.0~29 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=cdc4e129f5ab6d60db16f415b05a7ec9dd9a86b8 Lock file must stay opened till the very end of the program --- diff --git a/main.go b/main.go index c05d3c7..80cdc9a 100644 --- a/main.go +++ b/main.go @@ -228,9 +228,11 @@ func main() { log.Fatal(err) } + var fdLock *os.File if v := os.Getenv(EnvOODTgtsFd); v != "" { fd := mustParseFd(v, EnvOODTgtsFd) - fdLock := mustParseFd(v, EnvOODTgtsLockFd) + fdLock = mustParseFd(v, EnvOODTgtsLockFd) + defer fdLock.Close() flock := unix.Flock_t{ Type: unix.F_WRLCK, Whence: io.SeekStart,