Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Unlink not deleting, Threading issue?

by taint (Chaplain)
on Jun 05, 2014 at 05:28 UTC ( [id://1088776]=note: print w/replies, xml ) Need Help??


in reply to Unlink not deleting, Threading issue?

Greetings, pimperator.

I'm gonna have to go with the file probably has a handle open on it. But I don't quite know what type of system you're attempting to do this on -- *NIX, Win*, {...}. Win* ain't got a (native) unlink (that I can recall). But of course, all the *NIX's do have unlink. I'm also not familiar with the peculiars with Perl on Win, and unlink. But the doc's say:

On error, unlink will not tell you which files it could not remove. If you want to know which files you could not remove, try them one at a time:
foreach my $file ( @goners ) { unlink $file or warn "Could not unlink $file: $!"; }
You will also need to pass -U flag to Perl.

If nothing else. Now you can at least attempt to track the unlinking of the files, to see why/what's going on.

Best wishes.

--Chris

¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

Replies are listed 'Best First'.
Re^2: Unlink not deleting, Threading issue?
by dave_the_m (Monsignor) on Jun 05, 2014 at 07:03 UTC
    You will also need to pass -U flag to Perl.
    No you won't. Unless the OP is trying (as root) to direcltly unlink a directory on an ancient UNIX variant, the -U flag is irrelevant.

    Dave.

      Greetings, dave_the_m.

      The OP (pimperator) mentions Super User twice in the post.

      ...the user has super-user privileges...
      and
      After doing some reading I see that unlink() will not work if the file is open or if the user doesn't have superuser privileges, which is not the case for both.
      Which is why I felt it pertinent to mention the -U flag.

      --Chris

      ¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

        But the -U flag is only for unlinking directories, not files, and even then it only works on a few ancient UNIX variants. Systems like Linux don't allow you unlink() directories with or without -U.

        And unless there's some documentation I missed, -U does not affect whether Windows can unlink opened files.

        Dave.

        A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Unlink not deleting, Threading issue?
by ikegami (Patriarch) on Jun 06, 2014 at 16:57 UTC
    ack, no! One uses -U when one wants to unlink directories, which is never! Use rmdir to remove directories. Don't use -U!
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Unlink not deleting, Threading issue?
by Anonymous Monk on Jun 07, 2014 at 16:37 UTC

    This is very dangerous advice. If someone did as you suggested and actually managed to unlink a directory, it would probably damage their filesystem.

    The worst part is that you copy/pasted the how to do it parts while leaving out the big red flags that are trying to keep us from doing something stupid and tragic.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1088776]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found