mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
lbutils/file: ignore close err if errno is EINTR
but DONT LOOP IT. see comment. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -717,10 +717,30 @@ xclose(int *fd)
|
|||||||
if (*fd < 0)
|
if (*fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* nuance regarding EINTR on close():
|
||||||
|
* EINTR can be set on error, but there's
|
||||||
|
* no guarantee whether the fd is then still
|
||||||
|
* open or closed. on some other commands, we
|
||||||
|
* loop EINTR, but for close, we instead skip
|
||||||
|
* aborting *if the errno is EINTR* - so don't
|
||||||
|
* loop it, but do regard EINTR with rval -1
|
||||||
|
* as essenitally a successful close()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* because we don't want to mess with someone
|
||||||
|
* elses file if that fd is then reassigned.
|
||||||
|
* if the operation truly did fail, we ignore
|
||||||
|
* it. just leave it flying in the wind */
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((rval = close(*fd)) < 0)
|
if ((rval = close(*fd)) < 0) {
|
||||||
|
if (errno != EINTR)
|
||||||
exitf("xclose: could not close");
|
exitf("xclose: could not close");
|
||||||
|
|
||||||
|
/* regard EINTR as a successful close */
|
||||||
|
rval = 0;
|
||||||
|
}
|
||||||
|
|
||||||
*fd = -1;
|
*fd = -1;
|
||||||
|
|
||||||
reset_caller_errno(rval);
|
reset_caller_errno(rval);
|
||||||
|
|||||||
Reference in New Issue
Block a user