|
From: Andy <que...@ya...> - 2008-03-07 17:09:16
|
If I remember correctly, when you spawn a child process, all open file handles in the parent are inherited by the child. Thus in your example, when popenn is called you will have two open file handles, one owned by the parent and one by the child. You are then closing one of them in the parent, but the one inherited by the child is left open. The unlink cannot then delete the file. I think on Unix, the unlink would succeed - it decrements the file usage count - and the file would be deleted when the child ended, releasing its handle and decrementing the usage count to 0. Some programs used this feature to delete a file from the filesystem before it was finished with - a kind of pending delete. I'm not sure whether this unlinking behaviour is reproduced on Windows - so you might find that it simply fails. E Lofstad wrote: > I have a situation where it appears Windows does not release a file after immediately after my program calls fclose() when there are redirected child processes active. Is this standard operation? Or an artifact of mingw libs working with ms libs? Is there a way to avoid this problem? > > -- |