summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2018-07-03 14:40:17 -0700
committerOri Bernstein <ori@markovcorp.com>2018-07-03 14:40:17 -0700
commit6042e40dd30c9e04934e635274a013f989695eb7 (patch)
tree8636e1dca7ce95bc80fc488a5ce835eb553316a5
parent1da035ab2c9e8cbbdda631bfc7023b9bced4e61a (diff)
downloadmc-6042e40dd30c9e04934e635274a013f989695eb7.tar.gz
Add nopipe function to disable sigpipe.
-rw-r--r--lib/std/syswrap+plan9.myr3
-rw-r--r--lib/std/syswrap+posixy.myr12
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr
index 7ca9c3c..fdfa704 100644
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -47,6 +47,7 @@ pkg std =
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
const pipe : (fds : fd[2]# -> errno)
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
+ const nopipe : (-> void)
/* useful/portable bits of stat */
const fmtime : (f : byte[:] -> result(time, errno))
@@ -121,6 +122,8 @@ const openmode = {path, opts, mode;
-> check(fd)
}
+const nopipe = {
+}
/* useful/portable bits of stat */
const fexists = {path
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index 23b8e04..b3b9baa 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -46,6 +46,7 @@ pkg std =
const pipe : (fds : fd[2]# -> errno)
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
+ const nopipe : (-> void)
/* useful/portable bits of stat */
const fmtime : (f : byte[:] -> result(time, errno))
@@ -89,6 +90,17 @@ const pipe = {fds; -> (sys.pipe((fds : sys.fd[2]#)) : errno)}
const seek = {fd, delta, whence; -> check(sys.lseek((fd : sys.fd), (delta : sys.off), (whence : sys.whence)))}
const dup2 = {ofd, nfd; -> check((sys.dup2((ofd : sys.fd), (nfd : sys.fd)) : fd))}
+const nopipe = {
+ var sa, osa
+
+ /* is there ever a time we care about sigpipe? */
+ sa = [
+ .handler = ({;} : byte#),
+ .flags = sys.Sarestart,
+ ]
+ sys.sigaction(sys.Sigpipe, &sa, &osa)
+}
+
/* path manipulation */
const mkdir = {path, mode; -> (sys.mkdir(path, mode) : errno)}
const chdir = {path; -> sys.chdir(path) == 0}