Skip to content

File not closed on timeout or SIGINT #28

@kdee-korreyd

Description

@kdee-korreyd

Issue

filelock-unix.c; file descriptor "filedes" is not closed if no lock is received (due to timeout or SIGINT). This can cause a bunch of files to be left open if using filelock through an interactive shell (R, rstudio, etc..)

Reproduce

session 1:

$ R --vanilla
> library(filelock)
> lock("/tmp/test.lck")
Lock on ‘/tmp/test.lck’

lsof:

$ lsof | grep "test.lck"
R          2504               jacobs    3u      REG   0,53        0    2393006 /tmp/test.lck

session 2:

$ R --vanilla
> library(filelock)
> lock("/tmp/test.lck",timeout=1)
NULL #<-- timeout, as expected

lsof:

# at this point I'd expect there to still only be 1 open file but...:
$ lsof | grep "test.lck"
R         11476               jacobs    3u      REG   0,53        0    2393006 /tmp/test.lck
R         17162               jacobs    3u      REG   0,53        0    2393006 /tmp/test.lck

Workaround

The workaround I am currently using for this can be found here:
#master...kdee-korreyd:closefile

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions