|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * Test whether classic NSPR's select() wrapper properly blocks |
|
8 * the periodic SIGALRM clocks. On some platforms (such as |
|
9 * HP-UX and SINIX) an interrupted select() system call is |
|
10 * restarted with the originally specified timeout, ignoring |
|
11 * the time that has elapsed. If a select() call is interrupted |
|
12 * repeatedly, it will never time out. (See Bugzilla bug #39674.) |
|
13 */ |
|
14 |
|
15 #if !defined(XP_UNIX) |
|
16 |
|
17 /* |
|
18 * This test is applicable to Unix only. |
|
19 */ |
|
20 |
|
21 int main() |
|
22 { |
|
23 return 0; |
|
24 } |
|
25 |
|
26 #else /* XP_UNIX */ |
|
27 |
|
28 #include "nspr.h" |
|
29 |
|
30 #include <sys/time.h> |
|
31 #include <stdio.h> |
|
32 #ifdef SYMBIAN |
|
33 #include <sys/select.h> |
|
34 #endif |
|
35 |
|
36 int main(int argc, char **argv) |
|
37 { |
|
38 struct timeval timeout; |
|
39 int rv; |
|
40 |
|
41 PR_SetError(0, 0); /* force NSPR to initialize */ |
|
42 PR_EnableClockInterrupts(); |
|
43 |
|
44 /* 2 seconds timeout */ |
|
45 timeout.tv_sec = 2; |
|
46 timeout.tv_usec = 0; |
|
47 rv = select(1, NULL, NULL, NULL, &timeout); |
|
48 printf("select returned %d\n", rv); |
|
49 return 0; |
|
50 } |
|
51 |
|
52 #endif /* XP_UNIX */ |