Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 6 Aug 2004 13:59:14 +0000 (GMT) From: Ghanshyam To: cygwin AT cygwin DOT com Subject: 1.5.5.1 unlink() unable to remove an open file. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII hi all, I am having a problem with unlink() system call. If the file is currently open by some other process then unlink() is unable to delete that file ( shown in 'ls' to that directory) but returns successfull! But after all filedescriptors open to that file are closed, the file is removed. But in linux, the 'file' is removed immediately after unlink() call, irrespective of how many other open filedescriptors are there for the 'file'. Is there any specific reason for such a behaviour by cygwin??? here are the test program (s) for the problem: /*************open_file.c*****************/ #include int main() { int i; FILE *p; p=fopen("test_file","r"); if(!p) perror("fopen"); else printf("fopen successful!!!\n"); scanf("%d",&i); /*prevent program termination*/ /*close the file*/ fclose(p); return 0; } /*********************************************/ /************* unlink_file.c******************/ #include int main() { int i; i=unlink("test_file"); if(i) perror("unlink"); else printf("unlink successful!!!\n"); printf("exiting main...\n"); return 0; } /***********************************************/ How to run? -------------- 1. copy these two files in some dir 2. create a file named 'test_file' withing the same dir 3. compile both the files. 4. first, run open_file.exe in a bash shell (after open it should wait for input, don't give any input at this point) 5. open a new shell and run unlink_file.exe (it should be successful) 6. type 'ls' on the shell , the file 'test_file' still shown. 7. now terminate open_file.exe program by giving some input, and 'ls' again on the dir. now 'test_file' is not shown and deleted!!! with thanks and regards, ghanshyam -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/