ref: 6042e40dd30c9e04934e635274a013f989695eb7
parent: 1da035ab2c9e8cbbdda631bfc7023b9bced4e61a
author: Ori Bernstein <ori@markovcorp.com>
date: Tue Jul 3 10:40:17 EDT 2018
Add nopipe function to disable sigpipe.
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -47,6 +47,7 @@
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 @@
-> check(fd)
}
+const nopipe = {
+}
/* useful/portable bits of stat */
const fexists = {path
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -46,6 +46,7 @@
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))
@@ -88,6 +89,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)}