public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jacob Cohen <cohen@rafb.net>
To: linux-kernel@vger.kernel.org
Subject: kernel 2.4.18 - select() returning strange value
Date: Fri, 7 Jun 2002 13:09:05 -0700	[thread overview]
Message-ID: <12812896964.20020607130905@rafb.net> (raw)

Hello everyone.

Please CC: me on replies

Summary: when calling select() on a set of file descriptors containing
only the descriptor of a non-connected stream socket, select() returns
1 and marks the FD set as if data were waiting on the socket.


Details: I first noticed, when trying to install the perl module
Net::Telnet, that the select test was failing. Running strace on the
test program, I determined that select() was returning an unexpected
value.
I wrote a simple C program to duplicate this behavior, and got the
same results.

sock = socket(AF_INET, SOCK_STREAM, 6);
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
tv.tv_sec = 0; tv.tv_usec = 0;
retval = select(sock+1, &rfds, NULL, NULL, &tv);

Produced these strace lines:

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
select(4, [3], NULL, NULL, {0, 0}) = 1 (in [3], left {0, 0})

According to what I've read in the man pages for select() and
socket(), a nonconnected socket should be unreadable, and therefore
select() should timeout and return 0. I cannot figure out why it is
returning 1.

I've gotten this result on kernel 2.4.18, and someone confirmed the
same result on 2.4.19-pre7. A user with 2.2.19 ran my test program and
got a return value of 0, which is what I would expect the return value
to be.

Has something changed in the kernel or the way the select() syscall
behaves on a nonconnected socket that I should be aware of? I cannot
find anything relevant in the recent change logs, but I am probably
missing something.

Any insight into this would be much appreciated. Thanks in advance.

-- 
Regards,
Jake                          mailto:cohen@rafb.net


             reply	other threads:[~2002-06-07 20:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-07 20:09 Jacob Cohen [this message]
2002-06-09  1:57 ` kernel 2.4.18 - select() returning strange value David Schwartz
  -- strict thread matches above, loose matches on Subject: below --
2002-06-10  6:22 Borsenkow Andrej

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12812896964.20020607130905@rafb.net \
    --to=cohen@rafb.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox