caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* file mapped bigarray and Unix.unlink
@ 2009-07-02  8:10 Matthieu Dubuget
  2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
  2009-07-02 12:48 ` Florian Hars
  0 siblings, 2 replies; 6+ messages in thread
From: Matthieu Dubuget @ 2009-07-02  8:10 UTC (permalink / raw)
  To: caml-list

Hello,

I have difficulties to delete one file (name: fn, file descriptor:
fdesc) with "Unix.unlink fn".

I suspect that this is because I have a bigarray ba mapped with fdesc.
Is it a possible reason?

At some point, I want to delete fn because the saving operation was
cancelled by the user.

I assure that the binding to ba is lost.

Then, I close the file handle with
"Unix.close fdesc;"

At this point,
"Unix.rename fn g;" works, but
 
"Unix.unlink fn;" fails with : Permission denied error.


following my idea that this can be due to the fact that fn is mapped in
memory, I tried to insert a Gc.compact, in order for ba to be erased:

Unix.close fdesc;
Gc.compact ();
Unix.unlink fn;

but got the same error message.

Any idea?

Salutations

Matt




^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Caml-list] file mapped bigarray and Unix.unlink
@ 2009-07-02 12:43 Dario Teixeira
  0 siblings, 0 replies; 6+ messages in thread
From: Dario Teixeira @ 2009-07-02 12:43 UTC (permalink / raw)
  To: matthieu.dubuget, David MENTRE; +Cc: caml-list


Hi,

> > The strategy I adopted is to spawn a recursive thread that
> > periodically try to erase the file until success.
> 
> That seems the wrong solution to me. The unlink syscall should work
> immediately or you have another reason why it only works after a
> certain time.

I second David's discomfort.  Have you considered issuing a sync after
the unlink?  For efficiency reasons the OS may not actually be deleting
the file immediately after the unlink; the sync should force it to do it.

Cheers,
Dario Teixeira






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-02 12:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02  8:10 file mapped bigarray and Unix.unlink Matthieu Dubuget
2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
2009-07-02  9:49   ` David MENTRE
2009-07-02 10:15     ` Matthieu Dubuget
2009-07-02 12:48 ` Florian Hars
2009-07-02 12:43 Dario Teixeira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).