I'm working with a program that uses qdbm to maintain a key-value store (qdbm is linked into the program). In certain cases, the process puts a value in the qdbm database and then restarts itself by calling an external init script (via system()). It appears that sometimes a value written to the qdbm database doesn't actually stick, and I'm wondering if it could be due to the data not getting flushed to disk before the process is killed via SIGTERM.
Since qdbm does writes using the write() system call (versus say, the fwrite() library function), I would think that the Linux kernel should know to flush everything to disk eventually (the system doesn't get restarted, just the process). Also, close() does get called on the FD before the process is killed.
So, is my understanding correct, or do I need to add some fdatasync() or similar calls in there somewhere? Links to authoritative references on the semantics here would also be appreciated.