|
Last change
on this file since 2527 was 2036, checked in by bird, 20 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /* Test for crashing bugs when trying to create too many timers. */
|
|---|
| 2 |
|
|---|
| 3 | #include <stdio.h>
|
|---|
| 4 | #include <time.h>
|
|---|
| 5 | #include <signal.h>
|
|---|
| 6 | #include <sys/time.h>
|
|---|
| 7 | #include <sys/resource.h>
|
|---|
| 8 | #include <unistd.h>
|
|---|
| 9 |
|
|---|
| 10 | #if _POSIX_THREADS
|
|---|
| 11 | # include <pthread.h>
|
|---|
| 12 |
|
|---|
| 13 | void
|
|---|
| 14 | thread (union sigval arg)
|
|---|
| 15 | {
|
|---|
| 16 | puts ("Timeout");
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | int
|
|---|
| 20 | do_test (void)
|
|---|
| 21 | {
|
|---|
| 22 | int i, res;
|
|---|
| 23 | timer_t timerId;
|
|---|
| 24 | struct itimerspec itval;
|
|---|
| 25 | struct sigevent sigev;
|
|---|
| 26 |
|
|---|
| 27 | itval.it_interval.tv_sec = 2;
|
|---|
| 28 | itval.it_interval.tv_nsec = 0;
|
|---|
| 29 | itval.it_value.tv_sec = 2;
|
|---|
| 30 | itval.it_value.tv_nsec = 0;
|
|---|
| 31 |
|
|---|
| 32 | sigev.sigev_notify = SIGEV_THREAD;
|
|---|
| 33 | sigev.sigev_signo = SIGRTMIN;
|
|---|
| 34 | sigev.sigev_notify_function = thread;
|
|---|
| 35 | sigev.sigev_notify_attributes = 0;
|
|---|
| 36 | sigev.sigev_value.sival_ptr = (void *) &timerId;
|
|---|
| 37 |
|
|---|
| 38 | for (i = 0; i < 100; i++)
|
|---|
| 39 | {
|
|---|
| 40 | printf ("cnt = %d\n", i);
|
|---|
| 41 |
|
|---|
| 42 | if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0)
|
|---|
| 43 | {
|
|---|
| 44 | perror ("timer_create");
|
|---|
| 45 | continue;
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | res = timer_settime (timerId, 0, &itval, NULL);
|
|---|
| 49 | if (res < 0)
|
|---|
| 50 | perror ("timer_settime");
|
|---|
| 51 |
|
|---|
| 52 | res = timer_delete (timerId);
|
|---|
| 53 | if (res < 0)
|
|---|
| 54 | perror ("timer_delete");
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | return 0;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | # define TEST_FUNCTION do_test ()
|
|---|
| 61 | #else
|
|---|
| 62 | # define TEST_FUNCTION 0
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 | #include "../test-skeleton.c"
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.