, C, SIGALARM, , , : statvfs ? ?
statvfs stat:
#include <sigaction.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
static void alarm_handler( int sig )
{
return;
}
.
.
.
int statvfs_try( const char *path, struct stat *s, unsigned int seconds )
{
struct sigaction newact;
struct sigaction oldact;
memset( &newact, 0, sizeof( newact ) );
memset( &oldact, 0, sizeof( oldact) );
sigemptyset( &newact.sa_mask );
newact.sa_flags = 0;
newact.sa_handler = alarm_handler;
sigaction( SIGALRM, &newact, &oldact );
alarm( seconds );
errno = 0;
int rc = stat( path, s );
int save_errno = errno;
alarm( 0 );
sigaction( SIGALRM, &oldact, NULL );
errno = saved_errno;
return( rc );
}