New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicit filehandle close not working when STDERR closed #16209
Comments
From @steve-m-hayCreated by @steve-m-hayI have recently noticed temporary files being left behind by It should be automatically closed when that function exits, but it Furthermore, I found that the problem weirdly only occurs with the The closure of STDERR is the key thing in that change, and the problem use strict; On Windows, the $file does not get deleted at the end and the output is: Opened test.txt. Press <ENTER> to close and unlink it... (Unfortunately, you probably won't see the problem as easily as that If I simply comment out the "close STDERR;" line then the $file does Opened test.txt. Press <ENTER> to close and unlink it... Perl Info
|
From @steve-m-hay |
From zefram@fysh.orgSteve Hay wrote:
Since you didn't open a new standard error stream deliberately, the next -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Wed, 25 Oct 2017 07:25:36 -0700, zefram@fysh.org wrote:
Or just close $fh explicitly. -- Father Chrysostomos |
From @steve-m-hayOn Wed, 25 Oct 2017 07:25:36 -0700, zefram@fysh.org wrote:
Thanks. I should have thought of that. Now fixed in https://perl5.git.perl.org/perl.git/commit/b2b30beea3 |
From @steve-m-hayOn Wed, 25 Oct 2017 08:45:45 -0700, sprout wrote:
Yes, that also works, but it's a shame that code such as that in write_compiler_script() can be affected from a distance like this. I've never considered it before, but clearly you can't rely on implicit close always working: due to possible interference from afar you must always explicitly close() if you really need the file to be closed. I'm wondering if a warning somewhere in the system might have helped here? Either when opening the file and finding that the stderr file descriptor has been used for it, or when refraining from doing the implicit close on that stream? Neither thing was what was expected/wanted in this case, but warnings would be annoying in other cases where these actions were intended. |
From @exodistWould be nice to have some control over file descriptors used in open. For Would also be nice to be able to tell open not to use any "special" -Chad On Wed, Oct 25, 2017 at 9:59 AM, Steve Hay via RT <perlbug-followup@perl.org
|
From @LeontOn Wed, Oct 25, 2017 at 7:54 PM, Chad Granum <exodist7@gmail.com> wrote:
perl -e 'open STDOUT, ">", "foo.txt" or die "Couldnt open: $!"; warn fileno Leon |
@steve-m-hay - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132358 (status was 'resolved')
Searchable as RT132358$
The text was updated successfully, but these errors were encountered: