raspberrypi/userland — pull request #71 by dmopalmer (2013-07-28 16:56:44+00:00)
Title: Adding --link option for latest complete timelapse frame

This option tells raspistill to make a link to its output file after it has completed writing and closing the file. By accessing the link instead of the -o file:

A) if you want the most recent image in a time-lapse, you don't have to sort the filenames by frame number and pick the last.* For something like a web page, you can always use the linkname to get the current frame.

B) You don't have to worry about reading a partially-written frame. If you just take the most recent file, you could run into the case where it is half-written and you get an ugly half-image/half-garbage display. The linkname always** points to a fully-formed static file which no-one else is writing to.

*Maybe the documentation for timelapse should include the suggestion of using %05d instead of %d for better sorting behavior.

**There is a brief window between the unlinking of the previous frame and the linking of the new. Ideally these two operations should be made atomic, but I don't know how to do that. The consequence of that race condition is that the reader's 'open()' will fail with a file not found, which is better than the alternative of a silent read of garbage.