selintr.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. * Test whether classic NSPR's select() wrapper properly blocks
  7. * the periodic SIGALRM clocks. On some platforms (such as
  8. * HP-UX and SINIX) an interrupted select() system call is
  9. * restarted with the originally specified timeout, ignoring
  10. * the time that has elapsed. If a select() call is interrupted
  11. * repeatedly, it will never time out. (See Bugzilla bug #39674.)
  12. */
  13. #if !defined(XP_UNIX)
  14. /*
  15. * This test is applicable to Unix only.
  16. */
  17. int main()
  18. {
  19. return 0;
  20. }
  21. #else /* XP_UNIX */
  22. #include "nspr.h"
  23. #include <sys/time.h>
  24. #include <stdio.h>
  25. int main(int argc, char **argv)
  26. {
  27. struct timeval timeout;
  28. int rv;
  29. PR_SetError(0, 0); /* force NSPR to initialize */
  30. PR_EnableClockInterrupts();
  31. /* 2 seconds timeout */
  32. timeout.tv_sec = 2;
  33. timeout.tv_usec = 0;
  34. rv = select(1, NULL, NULL, NULL, &timeout);
  35. printf("select returned %d\n", rv);
  36. return 0;
  37. }
  38. #endif /* XP_UNIX */