As of version 4.0, samhain allows to perform a wait on check operation which waits on the end of the current filesystem scan and indicates the result via the exit status:
samhain -w seconds
The argument for this option is the timeout. The maximum timeout value is 86400 (one day). A timeout of zero is interpreted as no timeout. A negative timeout is interpreted in the following way:
First, wait until the Samhain daemon has initalized.
Then, wait for the end of the filesystem scan with a timeout of (abs(seconds) - 1). I.e. a timeout of -1 will become 0, a timeout of -601 seconds will become 600 seconds.
The exit status has the following meaning:
0
The deamon currently performs no file system scan, and no issues have been reported in the last scan.
1
The deamon currently performs no file system scan, and one or more issues have been reported in the preceding scan.
2
The wait operation has timed out while the deamon was performing a file system scan.
3
An error has occured. Usually this would be either an access error (the wait operation needs at least group privilege), or a non-negative argument has been given and the deamon has not yet initialized (or isn't running).