summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-25 02:39:08 (GMT)
committerRich Felker <dalias@aerifal.cx>2012-09-25 02:39:08 (GMT)
commit82dc1e2e783815e00a90cd3f681436a80d54a314 (patch)
tree4cf63d5f1c3e10255033200531ca214eca3aa7fe
parent4b49060da09b37e36ae08b49499c4a53b4f53890 (diff)
downloadmusl-82dc1e2e783815e00a90cd3f681436a80d54a314.tar.gz
fix handling of EINTR during close()
austin group interpretation for defect #529 (http://austingroupbugs.net/view.php?id=529) tightens the requirements on close such that, if it returns with EINTR, the file descriptor must not be closed. the linux kernel developers vehemently disagree with this, and will not change it. we catch and remap EINTR to EINPROGRESS, which the standard allows close() to return when the operation was not finished but the file descriptor has been closed.
-rw-r--r--src/unistd/close.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/unistd/close.c b/src/unistd/close.c
index 728d729..e8f813d 100644
--- a/src/unistd/close.c
+++ b/src/unistd/close.c
@@ -1,8 +1,11 @@
#include <unistd.h>
+#include <errno.h>
#include "syscall.h"
#include "libc.h"
int close(int fd)
{
- return syscall_cp(SYS_close, fd);
+ int r = __syscall_cp(SYS_close, fd);
+ if (r == -EINTR) r = -EINPROGRESS;
+ return __syscall_ret(r);
}