Problem
It is imperative that I have usleep(S) functionality in my OpenServer Development System Release 5.0.0 or 5.0.2. I understand, as stated in TA100778, that this system call is not included. However, it is necessary that I have it as a temporary patch or one-off.
Cause
The usleep(S) library call is defined as part of the X/Open Compatibility Guide Issue 4, Version 2 (XPG4.2), also known as "Spec-1170" or the X/Open "Single Unix Specification".
Currently, the SCO OpenServer Development System Release 5 fully conforms to the previous version of XPG4, but not to Version 2.
Although documented, the library routine usleep(S) is not currently included in any of the development libraries for SCO OpenServer Release 5.
Solution
The following is the source code for the usleep(S) routine. You
will be able compile this code into a new library, or can
merge the code with an existing library.#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>int usleep(unsigned int useconds)
{
struct timeval temptval; if (useconds <= 0) return;
temptval.tv_sec = useconds / 1000000;
temptval.tv_usec = useconds % 1000000;
if (select(0,NULL,NULL,NULL,&temptval) == -1 && errno != 4)
{
perror("sleep with select");
exit(1);
}
}NOTE: usleep functionality is included in SCO OpenServer Development
System Release 5.0.4. See also
TA100778, "Using fattach(), usleep() or expm1() results in "undefined symbol" linker error."