four-argument version of select

John R. Comeau comeaujr at sd.conexant.com
Sun Jun 11 16:39:20 CDT 2000


~sdpm~
I'm trying to use the four-argument select function.  I'm having
trouble getting the timeout feature to work as I expected.  For
instance, I have the following code to read from a FIFO (named pipe):

	open FIFO, $fifo	or die "can't read $fifo: $!";
	my $rin = '';
	vec ($rin, fileno (FIFO), 1) = 1;
	my $nfound = select ($rin, undef, undef, 1);

I expected that it will wait for one second to see if the FIFO had
data available to read and then timeout and continue execution.  But
it never times out.

Instead of timing out, I see it wait at the select call until data is
written to the fifo.  For those of you with accounts on apsadmin
(SDPM's) computer, I have the cases I've tried in the following files:

prw-rw-rw-   1 comeau     users            0 Jun 11 14:11 /home/comeau/fifo
-rw-r--r--   1 comeau     users            6 Jun 10 17:57 /home/comeau/hello
-rwxr-xr-x   1 comeau     users          465 Jun 10 18:06 /home/comeau/select.pl
-rwxr-xr-x   1 comeau     users          465 Jun 10 18:06 /home/comeau/select2.pl
-rwxr-xr-x   1 comeau     users           52 Jun 11 14:14 /home/comeau/select3.pl

What I did to test these out is ran select.pl (or select2.pl) in one
shell, and in another shell, ran

	cat < hello > fifo

I find that select2.pl waits for data to be written to fifo before
continuing.  I gave world write permissions to the file
/home/comeau/fifo, so everyone should be able to duplicate my
experiment.

I've been unsuccessful with the FIFO with the following versions of
Perl:

	version 5.005_03 built for PA-RISC1.1
	version 5.005_02 built for sun4-solaris
	v5.6.0 built for sun4-solaris

However I did get the simple case to timeout as
expected:

	select undef, undef, undef, 4.75;

This is equivalent to a sleep for 4.75 seconds and is done in
select3.pl.

-- 
John Comeau (john.comeau at conexant.com) 858-713-3593 (W)
-------------------------------------------------------
Er hatte sich entschieden, ihre schmutzige Wasche in aller Offentlichkeit zu waschen
He had decided to wash their dirty linen in public
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list