소스 검색

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.
Rich Felker 12 년 전
부모
커밋
82dc1e2e78
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      src/unistd/close.c

+ 4 - 1
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);
 }