Filehandle STDOuT reopened as $fh only for input

X

xhoster

I got a warning of

Filehandle STDOUT reopened as $fh only for input...

On which perldiag expands thus:

Filehandle %s reopened as %s only for input
(W io) You opened for reading a filehandle that got
the same filehandle id as STDOUT or STDERR. This
occured because you closed STDOUT or STDERR previ-
ously.

Right, I did close STDOUT previously. But so what? This sounds more
like an amusing anecdote than a warning. Is something bad likely to happen
because of this confluence of file descriptors? If so, under what
circumstances? If not, then why is this a warning?

Thanks,

Xho
 
C

ced

I got a warning of

Filehandle STDOUT reopened as $fh only for input...

On which perldiag expands thus:

Filehandle %s reopened as %s only for input
(W io) You opened for reading a filehandle that got
the same filehandle id as STDOUT or STDERR. This
occured because you closed STDOUT or STDERR previ-
ously.

Right, I did close STDOUT previously. But so what? This sounds more
like an amusing anecdote than a warning. Is something bad likely to happen
because of this confluence of file descriptors? If so, under what
circumstances? If not, then why is this a warning?

Did you already see this:

http://groups.google.com/group/perl...t"+group:*perl*&rnum=7&hl=en#1840fa35819a10b8

If I read correctly, this was introduced because Perl needs to re-use
the
lowest file descriptor available -- in this case fd 1. The obvious
solution
of having Perl bump past fd 1 apparently isn't viable either.

But fd 1, if re-opened, needs to act STDOUT-ish. I didn't follow
exactly
why. So the warning is for innocents who who don't realize that.

The thread mentions you need to re-open STDOUT to /dev/null to avoid
these ensuing problems. Opening with '+<' seems to work too.
 
X

xhoster

Did you already see this:

http://groups.google.com/group/perl.perl5.porters/browse_thread/thread/4d
550adeddf6f6c7/1840fa35819a10b8?lnk=st&q=reopened+%22only+for+input%22+gr
oup%3A*perl*&rnum=7&hl=en#1840fa35819a10b8

Surprisingly no, since I saw a few other threads in that group on that
subject. I guess I should have replaced the first %s with STDOUT when I
googled on the diag message.

If I read correctly, this was introduced because Perl needs to re-use
the
lowest file descriptor available -- in this case fd 1. The obvious
solution
of having Perl bump past fd 1 apparently isn't viable either.

But fd 1, if re-opened, needs to act STDOUT-ish. I didn't follow
exactly
why. So the warning is for innocents who who don't realize that.

I guess that is one of the things that is disturbing me. On the one hand,
it doesn't seem to need to act STDOUT-ish, as my code runs fine. On the
other hand, code that seems to run fine yet produces warnings often stops
running fine under some conditions. I just wish it would tell what those
conditions are. From the porters thread, I'm guessing the likely problem
is that, if it fork, the child may become confused.
The thread mentions you need to re-open STDOUT to /dev/null to avoid
these ensuing problems. Opening with '+<' seems to work too.

I'd rather not open to /dev/null, as then attempts to print to the "closed"
STDOUT would not generate warning, like they should. Maybe I should
re-open it so that it goes to STDERR. Or I guess I could just live with,
or disable, the warning.

Thanks,

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top