Thread (13 messages) flat view 13 messages, 4 authors, 2016-06-15

Re: [Updated PATCH 1/2] Report exec errors from run-command

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:47:57

On Wed, Dec 30, 2009 at 11:52 AM, Ilari Liusvaara
[off-list ref] wrote:
+static inline void force_close(int fd)
+{
+       while (close(fd) < 0 && errno != EBADF)
+               ; /* No-op */
+}
+
According to http://linux.die.net/man/2/close, close can set errno to
EBADF, EINTR, or EIO. Currently, you're retrying on EINTR and EIO.
When we get EIO, are you sure it makes sense to retry? I'd imagine
that error would most likely just repeat itself, leading to an
infinite loop. How about "while (close(fd) < 0 && errno == EINTR)"
instead? I've seen other functions (like xread in wrapper.c) only
retry on those errors that it expects. In xreads case, it's not
retrying on EIO.

Perhaps it's OK still, since force_close() is only used on pipes. I
don't know if closing a pipe can generate EIO or not.

-- 
Erik "kusma" Faye-Lund
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help