help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

opening twice with O_RDWR


From: Mike - EMAIL IGNORED
Subject: opening twice with O_RDWR
Date: Sat, 30 Dec 2006 23:34:47 -0500
User-agent: Pan/0.14.2.91 (As She Crawled Across the Table)

On FC4 with g++ (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8):

In the code fragment below, I would have expected a
failure on the second open, but I find this is not
the case.  I would like to generate a failure.  How
can I do this?  The file is usually, but not always
present before the program is run.

Thanks for your help.
Mike.

   const char* const      filePath = "a_file";

   int handle1 = ::open(filePath,O_RDWR|O_CREAT,0600);
   if (handle1 < 0)
      cerr << "fail1" << endl;

   int handle2 = ::open(filePath,O_RDWR|O_CREAT,0600);
   if (handle2 < 0)
      cerr << "fail2" << endl;







reply via email to

[Prev in Thread] Current Thread [Next in Thread]