Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix race conditions reading/writing datafile #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meonkeys
Copy link

@meonkeys meonkeys commented Mar 8, 2013

Description and repro:

If several processes simultaneously try to read and write the datafile,
you may wind up with an empty datafile.

I noticed this when opening up many shells at once with screen -c dev,
where dev contains:

source /etc/screenrc
screen -t home
chdir /tmp
screen -t tmp1
screen -t tmp2
screen -t tmp3
screen -t tmp4
screen -t tmp5

In one or more of the screen windows I see

mv: cannot stat `/home/adamm/.j.tmp': No such file or directory

and I notice my datafile has been truncated.

Description and repro:

If several processes simultaneously try to read and write the datafile,
you may wind up with an empty datafile.

I noticed this when opening up many shells at once with `screen -c dev`,
where `dev` contains:

    source /etc/screenrc
    screen -t home
    chdir /tmp
    screen -t tmp1
    screen -t tmp2
    screen -t tmp3
    screen -t tmp4
    screen -t tmp5

In one or more of the screen windows I see

    mv: cannot stat `/home/adamm/.j.tmp': No such file or directory

and I notice my datafile has been truncated.
@kevinlsw
Copy link

I tried to use this on OSX, but apparently flock isn't available there. Any alternatives?

@meonkeys
Copy link
Author

I don't know, sorry. :(

@sengaya
Copy link

sengaya commented Jul 3, 2014

I tried to use this on OSX, but apparently flock isn't available there. Any alternatives?

Not sure if you really want to use this, but: http://stackoverflow.com/a/13343904/1306877

@rupa
Copy link
Owner

rupa commented Jul 10, 2014

I'm not really trying to maintain this project. https://github.com/rupa/z/ is actively maintained, has better features, and doesn't suffer from this particular bug (anymore) :)

(Sad that flock isn't available on OSX tho)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants