in reply to Re^6: Bad file descriptor when trying to close file handle
in thread Bad file descriptor when trying to close file handle

> See the post I just made in parallel to yours.

I know about inodes

But the question remains:

How can I revive/move an "invisible" file into the directory?

link doesn't seem to accept FHs.

use strict; use warnings; use Data::Dump qw/ddx/; use autodie; my $dir = "/tmp"; my $file = "$dir/tst_unlink"; open my $fh, ">>", $file; print $fh "ENTRY ".__LINE__; ddx <$file*>; unlink $file; print $fh "ENTRY ".__LINE__; ddx <$file*>; eval { link $fh, "${file}_new"; } or warn $@; eval { link $file, "${file}_new"; } or warn $@; ddx <$file*>; __DATA__
OUTPUT:
# open_unlink.pl:16: "/tmp/tst_unlink" # open_unlink.pl:22: () Can't link($fh, '/tmp/tst_unlink_new'): Datei oder Verzeichnis nicht g +efunden at ./open_unlink.pl line 24 Can't link('/tmp/tst_unlink', '/tmp/tst_unlink_new'): Datei oder Verze +ichnis nicht gefunden at ./open_unlink.pl line 26 # open_unlink.pl:29: ()

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

PS: FWIW: I was guessing, I can't run a full diagnosis for every fuzzy bug question, even after reading it thrice.

Replies are listed 'Best First'.
Re^8: Bad file descriptor when trying to close file handle
by ikegami (Patriarch) on Mar 03, 2022 at 16:05 UTC

    How can I revive/move an "invisible" file into the directory?

    I hadn't read the second half of your post, just the part I commented on.

    I don't know if it's possible. I doubt there exists a portable solution, but I suspect Linux might have one.

      My searching came up empty.

        FWIW: I remembered those Lost+Found directories which are sometimes populated after a crash.

        But seems only to help with fully orphaned inodes, and not those which still have an opened filehandle.

        Disclaimer: I don't consider myself a linux-guru (still rather a disciple ;-)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery