diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-01 21:00:50 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-01 21:00:50 +0100 |
| commit | 8e90c35945a3a02ece21c5b518cad5b5b0480bc9 (patch) | |
| tree | a1faf5b513a0482f663175928de01b6fc7b4ac03 | |
| parent | 2d69d45e26a0156cbafdff76c97ddb54cfe3f9e4 (diff) | |
lbutils/file: ignore close err if errno is EINTR
but DONT LOOP IT. see comment.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/libreboot-utils/lib/file.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c index a788d4af..0455c5f2 100644 --- a/util/libreboot-utils/lib/file.c +++ b/util/libreboot-utils/lib/file.c @@ -717,8 +717,23 @@ xclose(int *fd) if (*fd < 0) 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; - if ((rval = close(*fd)) < 0) + if ((rval = close(*fd)) < 0 && errno != EINTR) exitf("xclose: could not close"); *fd = -1; |
