in reply to Re: Re: Re: Re: New warnings Perl 5.8.3 in IO/File
in thread New warnings Perl 5.8.3 in IO/File

My gripe is that I dont care that fh 0 has been reused - how do I tell IO::File to not emit this new 5.8.3 warning?
perldoc warnings
  • Comment on Re: Re: Re: Re: Re: New warnings Perl 5.8.3 in IO/File

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: New warnings Perl 5.8.3 in IO/File
by ysth (Canon) on Mar 24, 2004 at 06:05 UTC
    Since warnings are lexical, you can't control what warnings IO::File will have enabled.

    Jeff, when I get a chance I will try it for myself; I don't see when the close of STDIN is actually happening right off. Does opening STDIN to /dev/null after the open3 call help or not?

      The call to open3() opens STDIN for reading in the child process and closes it in the run harness. Adding

      # This opens FH0 to prevent File::IOs new 5.8.3 warning FileHandle->new("</dev/null") or die "unable to open /dev/null: $!" # Alternatively, open the next file READ as well as write FileHandle->new("<>$pidFile") or die "unable to open $pidFile: $!"

      just after the open3() call prevents File::IO from warning, because FH0 is opened for read.

      Ughhh! I will do this for the moment, but this is the first time I can ever recall having to do something unnecessary to suppress a warning. I have, until now always treated warnings as something I NEVER want to do, sigh - IMHO this devalues my 'Absolutely No Warnings' tenet.

      Regards,

      Jeff

        I don't think it violates your tenet; leaving STDIN closed is really something you never want to do, and that's just what you are avoiding. However, (without having actually looked at it) I don't think the run harness should be closing STDIN when you pass it like that.

        I don't think "<>" would work. Try "+<" or "+>".

        I would do it as: open STDIN, "</dev/null" or die ... so perl's STDIN looks open as well as file descriptor 0.