! * Closes a file descriptor and returns the result, similar to close(2). Unlike close(2), guarantees that the file descriptor is closed even if EINTR error happens. * * Some systems don't close the file descriptor in case if the thread is interrupted by a signal and close(2) returns EINTR. * Other (most) systems do close the file descriptor even when when close(2) returns EINTR, and attemptin
| 315 | * behaves differently between systems. |
| 316 | */ |
| 317 | inline int close_fd(int fd) |
| 318 | { |
| 319 | #if defined(hpux) || defined(_hpux) || defined(__hpux) |
| 320 | int res; |
| 321 | while (true) |
| 322 | { |
| 323 | res = ::close(fd); |
| 324 | if (BOOST_UNLIKELY(res < 0)) |
| 325 | { |
| 326 | int err = errno; |
| 327 | if (err == EINTR) |
| 328 | continue; |
| 329 | } |
| 330 | |
| 331 | break; |
| 332 | } |
| 333 | |
| 334 | return res; |
| 335 | #else |
| 336 | return ::close(fd); |
| 337 | #endif |
| 338 | } |
| 339 | |
| 340 | #if defined(BOOST_FILESYSTEM_HAS_STATX) |
| 341 |