Hi All,
I need usleep command to use in one of my shell script. I am working on SunOS 5.9. Where usleep command is not available. Is there any way to use usleep command in SunOS.
Thanks In Advance,
chidhu
Hi All,
I need usleep command to use in one of my shell script. I am working on SunOS 5.9. Where usleep command is not available. Is there any way to use usleep command in SunOS.
Thanks In Advance,
chidhu
Not sure if this link can help you... have a look.
http://www.unix.com/high-level-programming/13079-using-usleep-c-diff-platforms.html
Thanks very much for your reply. I have checked that but usleep is called in C++ program, where I want to use usleep command which is there in debian OS.
Thanks,
chidhu
On Solaris usleep is implemented using SIGALARM. There is no command line implementation. If you need one you need to roll your own.
Please try our search function. You might find stuff like this: Sleep less than 1 second
And there are other threads with other solutions.
This works on Solaris:
#include <stdlib.h>
#include <time.h>
int main( int argc, char **argv )
{
struct timespec ts;
if ( argc < 2 ) return( -1 );
*( ( ldiv_t * ) &ts ) = ldiv( 1000000L * strtol( argv[ 1 ], NULL, 0 ), 1000000000L );
return( nanosleep( &ts, NULL ) );
}
Yeah, I played some casting games to get around assigning an ldiv_t to a struct timespec. But since they're both "struct { long, long }", it works.