On Wed, Apr 19, 2017 at 05:05:31PM +0300, Rowan Thorpe wrote:
> > On my server this is currently no problem, as I kill the process only at
> > times
> > when it is not yet starting the next fetch. Still it would be better of
> > course.
> The race-conditions I mention are not about the script being stopped
Correct. Sorry my confusion! Killing the process is handled by 'protect' anyway,
as you noted.
> * when the script is processing a file at the same time the
> mail-server is delivering to it (causing processing of an unfinished
> message at the end of the file)
> * rewinding/truncating the file at the end of processing at the same
> time the mail-server is delivering to it (not sure what that would
> cause, but I doubt it would be good)
> The chances of those things happening are low, but not zero.
> > "postfix -l" doesn't work here.
> Oops, I meant "postconf -l".
But what does it mean? PicoLisp's 'ctl' uses fcntl(), and sets a exclusive lock
(or shared lock if desired) on the whole file. So will this be obeyed by exim?
If so, it would be easy.
Another option that comes to mind is calling 'mv' on the file before opening it.
'mv' is atomic as long it is on the same device. If the file is still being
written it will all go to the same (old) file descriptor, and new messages
should re-create the file. If we wait after the 'mv' for one or two minutes,
things should be safe too.