mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
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:
parent
60dfabbeb7
commit
aecf3f55ce
2 changed files with 10 additions and 2 deletions
|
@ -933,10 +933,13 @@ static void waitToApplyUpdates(void)
|
||||||
OS forcibly closes the pipe), we will unblock. Then we can loop on
|
OS forcibly closes the pipe), we will unblock. Then we can loop on
|
||||||
kill() until the process is truly gone. */
|
kill() until the process is truly gone. */
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
struct timespec req;
|
||||||
|
req.tv_sec = 0;
|
||||||
|
req.tv_nsec = 100000000;
|
||||||
read(3, &x, sizeof (x));
|
read(3, &x, sizeof (x));
|
||||||
info("Pipe has closed, waiting for process to fully go away now.");
|
info("Pipe has closed, waiting for process to fully go away now.");
|
||||||
while (kill(options.waitforprocess, 0) == 0) {
|
while (kill(options.waitforprocess, 0) == 0) {
|
||||||
usleep(100000);
|
nanosleep(&req, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
qboolean stdinIsATTY;
|
qboolean stdinIsATTY;
|
||||||
|
|
||||||
|
@ -548,11 +549,15 @@ void Sys_Sleep( int msec )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
struct timespec req;
|
||||||
|
|
||||||
// With nothing to select() on, we can't wait indefinitely
|
// With nothing to select() on, we can't wait indefinitely
|
||||||
if( msec < 0 )
|
if( msec < 0 )
|
||||||
msec = 10;
|
msec = 10;
|
||||||
|
|
||||||
usleep( msec * 1000 );
|
req.tv_sec = msec/1000;
|
||||||
|
req.tv_nsec = (msec%1000)*1000000;
|
||||||
|
nanosleep(&req, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue