diff options
Diffstat (limited to 'src/sys/sys_unix.c')
-rw-r--r-- | src/sys/sys_unix.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index a170f21d..230d8c44 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -448,3 +448,31 @@ char *Sys_StripAppBundle( char *dir ) return cwd; } #endif // MACOS_X + + +/* +================== +Sys_Sleep + +Block execution for msec or until input is recieved. +================== +*/ +void Sys_Sleep( int msec ) +{ + fd_set fdset; + + FD_ZERO(&fdset); + FD_SET(fileno(stdin), &fdset); + if( msec < 0 ) + { + select((fileno(stdin) + 1), &fdset, NULL, NULL, NULL); + } + else + { + struct timeval timeout; + + timeout.tv_sec = msec/1000; + timeout.tv_usec = (msec%1000)*1000; + select((fileno(stdin) + 1), &fdset, NULL, NULL, &timeout); + } +} |