#include <nbdkit-plugin.h> int nbdkit_nanosleep (unsigned sec, unsigned nsec);
Overview
The utility function "nbdkit_nanosleep" suspends the current nbdkit(1) thread for "sec" seconds plus "nsec" nanoseconds.
Plugins or filters that need to sleep may call sleep(2), nanosleep(2) and similar. However that can cause nbdkit to delay excessively when shutting down (since the server must wait for any plugin or filter which is sleeping). The purpose of this function is to provide a way for sleeps to be interrupted when nbdkit is shutting down.
Use nbdkit_parse_delay(3) to parse delays and sleeps from configuration parameters for use by this function.
Return value
This function returns 0 if it slept at least as many seconds and nanoseconds as requested.
If there is an error it calls nbdkit_error(3) and returns -1. Attempts to sleep more than "INT_MAX" seconds are treated as an error.