/* ******************************************************************************* * 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: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/daemonsleep.c,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:38 $ * $Revision: 1.2 $ * Purpose : * ******************************************************************************* * * Change History * * $Log: daemonsleep.c,v $ * Revision 1.2 2002/10/07 09:37:38 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:36:55 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/daemonsleep.c,v 1.2 2002/10/07 09:37:38 mpoole Exp $" /* ------------------------------------------------------------------ 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 how_long ) { struct timeval sleep_period; fd_set readset; int rv; static int pipefd=-1; if (pipefd==-1) { pipefd = Get_Process_Pipe_fd( ); } if (pipefd != -1) { FD_ZERO( &readset ); FD_SET( pipefd, &readset ); sleep_period.tv_sec = how_long; sleep_period.tv_usec = 0; allow_sysint( ); rv = select( pipefd+1, &readset, NULL, NULL, &sleep_period ); if(rv==1) { /* read the byte from the fifo */ char tc; read( pipefd, &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 -- */