nsprpub/pr/tests/selintr.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/tests/selintr.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Test whether classic NSPR's select() wrapper properly blocks
    1.11 + * the periodic SIGALRM clocks.  On some platforms (such as
    1.12 + * HP-UX and SINIX) an interrupted select() system call is
    1.13 + * restarted with the originally specified timeout, ignoring
    1.14 + * the time that has elapsed.  If a select() call is interrupted
    1.15 + * repeatedly, it will never time out.  (See Bugzilla bug #39674.)
    1.16 + */
    1.17 +
    1.18 +#if !defined(XP_UNIX)
    1.19 +
    1.20 +/*
    1.21 + * This test is applicable to Unix only.
    1.22 + */
    1.23 +
    1.24 +int main()
    1.25 +{
    1.26 +    return 0;
    1.27 +}
    1.28 +
    1.29 +#else /* XP_UNIX */
    1.30 +
    1.31 +#include "nspr.h"
    1.32 +
    1.33 +#include <sys/time.h>
    1.34 +#include <stdio.h>
    1.35 +#ifdef SYMBIAN
    1.36 +#include <sys/select.h>
    1.37 +#endif
    1.38 +
    1.39 +int main(int argc, char **argv)
    1.40 +{
    1.41 +    struct timeval timeout;
    1.42 +    int rv;
    1.43 +
    1.44 +    PR_SetError(0, 0);  /* force NSPR to initialize */
    1.45 +    PR_EnableClockInterrupts();
    1.46 +
    1.47 +    /* 2 seconds timeout */
    1.48 +    timeout.tv_sec = 2;
    1.49 +    timeout.tv_usec = 0;
    1.50 +    rv = select(1, NULL, NULL, NULL, &timeout);
    1.51 +    printf("select returned %d\n", rv);
    1.52 +    return 0;
    1.53 +}
    1.54 +
    1.55 +#endif /* XP_UNIX */

mercurial