Technical article 100806

It is critical that I have the usleep(S) functionality in OpenServer 5.0.0/5.0.2.

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

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."

From the Xinuos technical article database, record 100806. Reproduced with permission. The original is at www.sco.com/ta/100806, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.