/* ******************************************************************************* * Copyright (c) 1997 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source$ * $Author$ * $Date$ * $Revision$ * Purpose : * ******************************************************************************* * * Change History * * $Log$ * ******************************************************************************* */ #ident "$Header$" /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include #include #ifdef INCLUDE_SYS_SELECT #include #endif #include #include #include /* ------------------------------------------------------------------ structures / defines ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Code starts here ------------------------------------------------------------------ */ int mp_daemon_sleep( int poll_fd, int how_long ) { struct timeval sleep_period; fd_set readset; int rv; if (poll_fd != -1) { FD_ZERO( &readset ); FD_SET( poll_fd, &readset ); sleep_period.tv_sec = how_long; sleep_period.tv_usec = 0; allow_sysint( ); rv = select( poll_fd+1, &readset, NULL, NULL, &sleep_period ); if(rv==1) { /* read the byte from the fifo */ char tc; read( poll_fd, &tc, 1 ); } deny_sysint( ); }else { sleep_period.tv_sec = how_long; sleep_period.tv_usec = 0; allow_sysint( ); rv = select( 0, NULL, NULL, NULL, &sleep_period ); deny_sysint( ); } return(rv); } /* -- End of File -- */