Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Shutting the Barn Door [File Locking]

Name: Anonymous 2011-01-20 16:21

Problem: The open call erases the file before the process has the lock

        open F, "> somefile"; # DERP you already erased all the data in somefile by opening it
        flock F, LOCK_EX;     # before obtaining this lock
        # Now write F
        close F;


Now you have two problems: +< still erases the file before the process has the lock

        open F, "+< somefile";
        flock F, LOCK_EX;
        truncate F, 0;
        # Now write F
        close F;


Dear /prog/, what am I missing?

Name: Anonymous 2011-01-20 17:07

>>7
man stat

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List