Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/build/pkgs/gap/patches/writeandcheck.patch
8818 views
1
diff -ru src/src/sysfiles.c b/src/sysfiles.c
2
--- src/src/sysfiles.c 2012-09-16 03:12:06.000000000 +0200
3
+++ b/src/sysfiles.c 2012-11-15 10:33:36.497514033 +0100
4
@@ -86,12 +86,17 @@
5
6
/* utility to check return value of 'write' */
7
ssize_t writeandcheck(int fd, const char *buf, size_t count) {
8
- int ret;
9
- ret = write(fd, buf, count);
10
- if (ret < 0)
11
- ErrorQuit("Cannot write to file descriptor %d, see 'LastSystemError();'\n",
12
+ static int depth = 0; /* Recursion depth */
13
+ int ret;
14
+ ret = write(fd, buf, count);
15
+ if (ret < 0 && depth == 0)
16
+ {
17
+ depth++;
18
+ ErrorQuit("Cannot write to file descriptor %d, see 'LastSystemError();'\n",
19
fd, 0L);
20
- return ret;
21
+ depth--;
22
+ }
23
+ return ret;
24
}
25
26
27
28