develooper Front page | perl.perl5.porters | Postings from March 2008

Re: [PATCH] Documentation fix for perlfunc/shutdown

Thread Previous | Thread Next
From:
Paul Fenwick
Date:
March 26, 2008 19:15
Subject:
Re: [PATCH] Documentation fix for perlfunc/shutdown
Message ID:
47EB0323.2010706@perltraining.com.au
G'day Nicholas/p5p,

Nicholas Clark wrote:

> I don't know. The code looks like this:

[snip]

>     PUSHi( PerlSock_shutdown(PerlIO_fileno(IoIFP(io)), how) >= 0 );

Forgive my poor knowledge of Perl's guts, but if I'm reading that correctly, 
we're pushing an integer return value based upon the return value of 
PerlSock_shutdown().  This means we can return '0' if we call 
PerlSock_shutdown but it fails (eg, filehandle isn't a socket).

This is backed up by:

	perl -wle'print shutdown(STDIN,1);'

which returns 0.  It looks like we only return undef if we reach the nuts 
label, the only path into which is:

     if (!io || !IoIFP(io))
	goto nuts;

This implies we return undef only when we don't have a valid filehandle 
(assuming that's what IoIFP is testing).

You've suggested:

>     Returns C<1> for success, C<undef> if the first argument is not a valid
>     filehandle, or if the C<shutdown> call failed for any reason, such as the
>     filehandle is not a socket.

So how about we combine everything into:

	Returns C<1> for success. In the case of error, returns
	C<undef> if the first argument is not a valid filehandle,
	or returns C<0> and sets C<$!> for any other failure.

A patch for the new wording is attached.

Cheerio,

	Paul

-- 
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About