[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: opening twice with O_RDWR
From: |
Paul Pluzhnikov |
Subject: |
Re: opening twice with O_RDWR |
Date: |
Sun, 31 Dec 2006 06:28:46 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> writes:
> In the code fragment below, I would have expected a
> failure on the second open,
Why would you expect that?
> I would like to generate a failure. How can I do this?
Use O_EXCL (which exists *just* for that purpose).
> The file is usually, but not always
> present before the program is run.
You can also stat() the file check whether it exists or not, then
change your program logic appropriateley.
> if (handle1 < 0)
> cerr << "fail1" << endl;
This is incorrect way to check for syscall failure.
Use "if (handle == -1)" instead (or your code will think that lsee()
past 2GB mark is a failure).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
- opening twice with O_RDWR, Mike - EMAIL IGNORED, 2006/12/30
- Re: opening twice with O_RDWR,
Paul Pluzhnikov <=
- Re: opening twice with O_RDWR, Mike - EMAIL IGNORED, 2006/12/31
- Message not available
- Re: opening twice with O_RDWR, Paul Pluzhnikov, 2006/12/31
- Re: opening twice with O_RDWR, Mike - EMAIL IGNORED, 2006/12/31
- Re: opening twice with O_RDWR, Paul Pluzhnikov, 2006/12/31
- Re: opening twice with O_RDWR, Paul Pluzhnikov, 2006/12/31
- Re: opening twice with O_RDWR, Mike - EMAIL IGNORED, 2006/12/31
- Re: opening twice with O_RDWR, Paul Pluzhnikov, 2006/12/31
- Re: opening twice with O_RDWR, Mike - EMAIL IGNORED, 2006/12/31
- Re: opening twice with O_RDWR, Paul Pluzhnikov, 2006/12/31