-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectsleep.cpp
52 lines (42 loc) · 916 Bytes
/
selectsleep.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* =====================================================================================
*
* Filename: slectsleep.cpp
*
* Description:
*
* Version: 1.0
* Created: 07/04/2014 04:16:04 PM CST
* Revision: none
* Compiler: gcc
*
* Author: (),
* Company:
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int msSleep ( unsigned int ms )
{
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = ms;
return select ( 0, NULL, NULL, NULL, &tv );
}
int main ( int argc, char* argv[] )
{
while ( 1 )
{
printf ( "test1\n" );
msSleep ( 800 * 1000 );
printf ( "test2\n" );
msSleep ( 800 * 1000 );
printf ( "test3\n" );
msSleep ( 800 * 1000 );
printf ( "test4\n" );
msSleep ( 800 * 1000 );
}
return 0;
}