From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 3 19:57:39 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43D6E16A421 for ; Thu, 3 Jan 2008 19:57:39 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout4.cac.washington.edu (mxout4.cac.washington.edu [140.142.33.19]) by mx1.freebsd.org (Postfix) with ESMTP id 2069B13C461 for ; Thu, 3 Jan 2008 19:57:39 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.139]) by mxout4.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.09) with ESMTP id m03JvPhx015321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jan 2008 11:57:25 -0800 X-Auth-Received: from dzihan.cs.washington.edu (dzihan.cs.washington.edu [128.208.4.96]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW07.09) with ESMTP id m03JvPRA005192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 3 Jan 2008 11:57:25 -0800 Message-ID: <477D3E25.4080807@u.washington.edu> Date: Thu, 03 Jan 2008 11:57:25 -0800 From: Garrett Cooper User-Agent: Thunderbird 2.0.0.6 (X11/20071003) MIME-Version: 1.0 To: Metin KAYA References: <1571995824.20080103205248@EnderUNIX.org> <20080103192245.GB90170@keira.kiwi-computer.com> <363446479.20080103213223@EnderUNIX.org> <477D3977.3030608@u.washington.edu> In-Reply-To: <477D3977.3030608@u.washington.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.4.1.325704, Antispam-Engine: 2.6.0.325393, Antispam-Data: 2008.1.3.113316 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Cc: freebsd-hackers@freebsd.org, "Rick C. Petty" Subject: Re: select X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2008 19:57:39 -0000 Garrett Cooper wrote: > Metin KAYA wrote: >> Yes Rick, I'm asking this "indefinitely" issue. Is there anything >> that handle this NULL situation a signal, or etc.? How does Linux or >> FreeBSD behave? >> >> >>> On Thu, Jan 03, 2008 at 08:52:48PM +0200, Metin KAYA wrote: >>> >>>> How select(2) will behave if I give the "utimeout" parameter as >>>> NULL? >>>> >> >> >>> According to the man page: >>> >> >> >>> If timeout is not a null pointer, it specifies the maximum >>> interval to >>> wait for the selection to complete. System activity can >>> lengthen the >>> interval by an indeterminate amount. >>> >> >> >>> If timeout is a null pointer, the select blocks indefinitely. >>> >> >> >>> To effect a poll, the timeout argument should not be a null >>> pointer, but >>> it should point to a zero-valued timeval structure. >>> >> >> >> >>> -- Rick C. Petty >>> >> >> >> -- Metin KAYA EnderUNIX >> Software Developer Endersys Software Engineer >> http://www.EnderUNIX.org/metin http://www.Endersys.com/ >> > Nevermind -- yes, block indefinitely, which implies that the program > won't proceed until it receives an umasked signal and exits or a file > descriptor becomes available in the 'infinite' time frame. > > That would essentially be the same as listen or send though with > blocking sockets, correct? > > -Garrett Give this beauty a shot [manually modified from the FC7 select(2) manpage]: #include #include int main() { fd_set rfds; FD_ZERO(&rfds); FD_SET(0, &rfds); printf("Wait for it...\n"); select(1, &rfds, NULL, NULL, NULL); printf("Done!\n"); return 0; } It will indefinitely block until you provide an EOF on the terminal (or have some other EOF'ed data written to STDIN for the program, i.e. via a pipe). Sending signals (apart from SIGIO -- 23) instantly kills the program as nothing's masked. SIGIO not killing the program is to be expected as per signal(7) and fcntl(2)'s manpage descriptions. Tested on an FC7 machine, so your mileage on a FreeBSD machine may differ. Cheers, -Garrett