Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/librumphijack Create a pipe on which to select. s...



details:   https://anonhg.NetBSD.org/src/rev/8372e4d3341c
branches:  trunk
changeset: 762803:8372e4d3341c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Mar 01 08:54:18 2011 +0000

description:
Create a pipe on which to select.  selecting on STDIN_FILENO seems
to be succesful *sometimes* on some archs (i'm suspecting this is
in some way related to lib/libc/ttyio/t_ttyio failing).

diffstat:

 tests/lib/librumphijack/h_client.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 072f041e637f -r 8372e4d3341c tests/lib/librumphijack/h_client.c
--- a/tests/lib/librumphijack/h_client.c        Tue Mar 01 08:48:41 2011 +0000
+++ b/tests/lib/librumphijack/h_client.c        Tue Mar 01 08:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_client.c,v 1.3 2011/02/20 23:45:46 pooka Exp $       */
+/*     $NetBSD: h_client.c,v 1.4 2011/03/01 08:54:18 pooka Exp $       */
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -50,21 +50,24 @@
        if (strcmp(argv[1], "select_timeout") == 0) {
                fd_set rfds;
                struct timeval tv;
+               int pipefd[2];
                int rv;
 
                tv.tv_sec = 0;
                tv.tv_usec = 1;
 
+               if (pipe(pipefd) == -1)
+                       err(1, "pipe");
                FD_ZERO(&rfds);
-               FD_SET(STDIN_FILENO, &rfds);
+               FD_SET(pipefd[0], &rfds);
 
-               rv = select(STDIN_FILENO+1, &rfds, NULL, NULL, &tv);
+               rv = select(pipefd[0]+1, &rfds, NULL, NULL, &tv);
                if (rv == -1)
                        err(1, "select");
                if (rv != 0)
                        errx(1, "select succesful");
 
-               if (FD_ISSET(STDIN_FILENO, &rfds))
+               if (FD_ISSET(pipefd[0], &rfds))
                        errx(1, "stdin fileno is still set");
                exit(0);
        } else if (strcmp(argv[1], "select_allunset") == 0) {



Home | Main Index | Thread Index | Old Index