Mostly as the title says; I would like to add support to my program such that it can detect when a particular volume or device is being unmounted/ejected, so that it can close file-handles for that volume and halt processing, such that the volume/drive can unmount without issues.
Currently I have a very basic database connection, but since it is seen as an open file-handle, it currently prevents the host volume from being unmounted or ejected at all until my program is closed. However, the program is intended to run as a daemon process, so really it needs to be able to close down in such cases.
Although I could try to create a working database elsewhere, there would still be the potential for syncing of changes to interrupt ejection of the disk, so I'd like a way to clean detect and avoid such issues.