tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

selintr.c (1201B)


      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() { return 0; }
     22 
     23 #else /* XP_UNIX */
     24 
     25 #  include "nspr.h"
     26 
     27 #  include <sys/time.h>
     28 #  include <stdio.h>
     29 
     30 int main(int argc, char** argv) {
     31  struct timeval timeout;
     32  int rv;
     33 
     34  PR_SetError(0, 0); /* force NSPR to initialize */
     35  PR_EnableClockInterrupts();
     36 
     37  /* 2 seconds timeout */
     38  timeout.tv_sec = 2;
     39  timeout.tv_usec = 0;
     40  rv = select(1, NULL, NULL, NULL, &timeout);
     41  printf("select returned %d\n", rv);
     42  return 0;
     43 }
     44 
     45 #endif /* XP_UNIX */