Inotify does not work (reliably) on pseudo file systems such as procfs(5) or devfs/devtmpfs.
True, but what I'm trying to do is get the writer "doing the right thing", or at least "doing the best under the circumstances".
Files are only really deleted if they are not opened (confer output of lsof() and their (hardlink) reference count hits zero. Similarly, as long as someone somewhere (e.g. another process) holds a valid FD to stdout, this stdout is not closed/“deleted”.
True, and that's one reason why unix doctrine has settled on a comparatively complex rename-and-copy sequence to handle reopening a file when a backup is to be saved. But I'd prefer not to rely on it when a Pascal-style Rewrite() is used, since this implies that a file is truncated and (potentially) that the space is reused.
So what I've coded for the time being is:
* When the instrument has generated data the file or pipe/FIFO/socket is closed.
* If it's a pipe/FIFO/socket it's reopened promptly, since this gives both ends the best chance of sorting things out.
* If it's a regular file it's not reopened until the next instrument run in case that causes data to be lost.
The interpretation of "promptly" will no doubt need to be adjusted, depending on the reliability of the inotify API and/or file timestamps etc.
As I've said though, this is really an attempt to "do the right thing" under different circumstances.
MarkMLl