Use nanosleep(2) instead of usleep(3)

usleep(3) was declared obsolete in POSIX.1-2001 and removed in
POSIX.1-2008 and nanosleep(2) was recommended to be used instead.
This commit is contained in:
Alan Zhao authored and GitHub committed 2024-05-15 18:14:52 -04:00
1 parent 60dfabbeb7
commit aecf3f55ce
2 files changed
+10 -2

No files matched your search

+6 -1
View File
@@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <fcntl.h>
#include <fenv.h>
#include <sys/wait.h>
#include <time.h>
qboolean stdinIsATTY;
@@ -548,11 +549,15 @@ void Sys_Sleep( int msec )
}
else
{
struct timespec req;
// With nothing to select() on, we can't wait indefinitely
if( msec < 0 )
msec = 10;
usleep( msec * 1000 );
req.tv_sec = msec/1000;
req.tv_nsec = (msec%1000)*1000000;
nanosleep(&req, NULL);
}
}