j2 icon indicating copy to clipboard operation
j2 copied to clipboard

fix race conditions reading/writing datafile

Open meonkeys opened this issue 13 years ago • 4 comments

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.

meonkeys avatar Mar 08 '13 18:03 meonkeys

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

kevinlsw avatar Apr 10 '13 20:04 kevinlsw

I don't know, sorry. :(

meonkeys avatar Apr 10 '13 22:04 meonkeys

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

sengaya avatar Jul 03 '14 12:07 sengaya

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)

rupa avatar Jul 10 '14 03:07 rupa