]> Cypherpunks.ru repositories - goredo.git/commitdiff
Lock file must stay opened till the very end of the program
authorSergey Matveev <stargrave@stargrave.org>
Sun, 1 Oct 2023 06:57:23 +0000 (09:57 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 1 Oct 2023 07:01:32 +0000 (10:01 +0300)
main.go

diff --git a/main.go b/main.go
index c05d3c777e2247d8a2b4ad69ef73aed78b571d92..80cdc9a8ed996917ef02be668f825fb915587b3c 100644 (file)
--- 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,