Subject: [Boost-bugs] [Boost C++ Libraries] #10506: Infinite loop in create_or_open_file
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-15 12:51:25
#10506: Infinite loop in create_or_open_file
------------------------------+--------------------------
Reporter: kevin.arunski@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
Version: Boost 1.56.0 | Severity: Problem
Keywords: |
------------------------------+--------------------------
This function will never exit if the call to ::open returns -1 for a
reason other than EEXIST.
inline file_handle_t create_or_open_file
(const char *name, mode_t mode, const permissions & perm =
permissions(), bool temporary = false)
{
(void)temporary;
int ret = -1;
//We need a loop to change permissions correctly using fchmod, since
//with "O_CREAT only" ::open we don't know if we've created or opened
the file.
while(1){
ret = ::open(name, ((int)mode) | O_EXCL | O_CREAT,
perm.get_permissions());
if(ret >= 0){
::fchmod(ret, perm.get_permissions());
break;
}
else if(errno == EEXIST){
if((ret = ::open(name, (int)mode)) >= 0 || errno != ENOENT){
break;
}
}
}
return ret;
}
For example if the call fails due to errno == EACCESS, the function does
not exit.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10506> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC