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 X-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: "Alex Vinokur" Subject: Removing the same file from two consoles Date: Thu, 11 Sep 2003 18:22:58 +0300 Lines: 215 Message-ID: X-Complaints-To: usenet AT sea DOT gmane DOT org X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Here is some program which was invocated on two consoles. The program behavior is different on * Cygwin, DJGPP on the one hand and * Mingw on the other hand environments. Which is right/correct/preferable? ========= C-code : BEGIN ========= /* File t.c */ #include #include #include #include #include int main(int argc, char** argv) { int rc; char ch; FILE* fp; int i; assert (argc > 1); printf ("Command line : "); for (i = 0; i < argc; i++) printf ("%s ", argv[i]); printf ("\n"); errno = 0; rc = access (argv[1], F_OK); printf ("access : rc = %d; errno = %u (%s)\n", rc, errno, strerror(errno)); errno = 0; rc = remove (argv[1]); printf ("remove : rc = %d; errno = %u (%s)\n", rc, errno, strerror(errno)); fp = fopen (argv[1], "w"); printf ("fopen : %s\n", (fp ? "OK" : "FAILURE")); printf ("Enter any key : "); scanf ("%c", &ch); errno = 0; rc = access (argv[1], F_OK); printf ("access : rc = %d; errno = %u (%s)\n", rc, errno, strerror(errno)); printf ("Thanks. Bye\n"); return 0; } ========= C-code : END =========== ######### Run via Cygwin : BEGIN ######### ========================================= Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927 (prerelease) ========================================= ==================================== Step 0. Compiling and getting status ==================================== ------ Console-0 ------ $ gcc t.c -o progc ----------------------- ================================================= Step 1. removing and fopening a file on Console-1 ================================================= ------ Console-1 ------ $ progc foo Command line : progc foo access : rc = -1; errno = 2 (No such file or directory) remove : rc = -1; errno = 2 (No such file or directory) fopen : OK Enter any key : ----------------------- ======================================================== Step 2. removing and fopening the same file on Console-2 ======================================================== ------ Console-2 ------ $ progc foo Command line : progc foo access : rc = 0; errno = 0 (No error) remove : rc = 0; errno = 0 (No error) fopen : FAILURE Enter any key : ----------------------- ====================================== Step 3. Entering some key on Console-2 ====================================== ------ Console-2 ------ ----- continuation ---- Enter any key : a access : rc = -1; errno = 13 (Permission denied) Thanks. Bye ----------------------- ====================================== Step 4. Entering some key on Console-1 ====================================== ------ Console-1 ------ ----- continuation ---- Enter any key : b access : rc = -1; errno = 2 (No such file or directory) Thanks. Bye ----------------------- ######### Run via Cygwin : END ########### ######### Run via Mingw : BEGIN ######### ==================== Windows 2000 MinGW 2.0.0.-2 GNU gcc version 3.2 =================== ==================================== Step 0. Compiling and getting status ==================================== ------ Console-0 ------ $ gcc t.c -o progm ----------------------- ================================================= Step 1. removing and fopening a file on Console-1 ================================================= ------ Console-1 ------ $ progm foo Command line : progm.exe foo access : rc = -1; errno = 2 (No such file or directory) remove : rc = -1; errno = 2 (No such file or directory) fopen : OK Enter any key : ----------------------- ======================================================== Step 2. removing and fopening the same file on Console-2 ======================================================== ------ Console-2 ------ $ progm foo Command line : progm.exe foo access : rc = 0; errno = 0 (No error) remove : rc = -1; errno = 13 (Permission denied) fopen : OK Enter any key : ----------------------- ====================================== Step 3. Entering some key on Console-2 ====================================== ------ Console-2 ------ ----- continuation ---- Enter any key : a access : rc = 0; errno = 0 (No error) Thanks. Bye ----------------------- ====================================== Step 4. Entering some key on Console-1 ====================================== ------ Console-1 ------ ----- continuation ---- Enter any key : b access : rc = 0; errno = 0 (No error) Thanks. Bye ----------------------- ######### Run via Mingw : END ########### ===================================== Alex Vinokur mailto:alexvn AT connect DOT to http://mathforum.org/library/view/10978.html ===================================== -- 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/