It is a relatively non-controversial fact that most people's attempts
to implement robust & recoverable resource serialisation
through advisory file locking, will fail under a myriad
of exceptional failure scenarios.
The most difficult of these to handle is complete systems failure
at critical points in the handshaking. That is, when both the
resource controller and the resource requester terminate simultaneously
with no possibility for cleanup, back out or status logging.
And even when starting with an expertly prepared and tested
scheme of operations, the process of adaption of that scheme
to the natural variations in application requirements, creates
ample opportunities to introduce subtle but fatal errors.
Upon restart, the advisory locks are simply forgotten;
pid files may exist but the processes no longer do;
or worse, the pids have been reallocated to completely unrelated processes.
And the shared resource transaction can be in any state.
Using the OPs example of a file transfer, the file in question
may not yet exist in the application space;
may exist in a partial form in the application space;
may exist in a completed form in the application space;
It may exist in the controller space in any of those three forms.
That is, the name of the file may have been recorded within the
transfer processes namespace, but the handover of the file
may not yet have started;
may have started but not completed;
may have completed but not been cleaned up.
And if the handover has completed and been cleaned up (in the application space)
the transfer may not yet have started;
may have started, but not yet been completed;
may have completed, but not been cleaned up;
In the absence of persistent and atomic, bilateral status recording,
a complete systems failure can leave either end of the transaction
with no information; or partial and differing information.
I've yet to see a resource serialisation scheme, based around advisory file locking, that gets it right in all scenarios. And I once wasted nearly 3 months on a critical project waiting for the experts to do so.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.