hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 487d842b528c2d851cd35ae9c07835da9af982c7
parent 2f3b9aa82299f68037b6223b588f752e94ae8e8b
Author: Egor <egor@opensrc.club>
Date:   Tue, 10 May 2022 20:03:53 +0300

unix: invert the meaning of CLOEXEC in pipe_flag

for consistency with sockets

Signed-off-by: Egor <egor@opensrc.club>

Diffstat:
Munix/+freebsd/pipe.ha | 7++++---
Munix/+linux/pipe.ha | 7++++---
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/unix/+freebsd/pipe.ha b/unix/+freebsd/pipe.ha @@ -6,9 +6,9 @@ use io; use rt; // Flags to use for the [[io::file]]s returned by [[pipe]] -// Only CLOEXEC and NONBLOCK are guaranteed to be available. +// Only NOCLOEXEC and NONBLOCK are guaranteed to be available. export type pipe_flag = enum { - CLOEXEC = rt::O_CLOEXEC, + NOCLOEXEC = rt::O_CLOEXEC, DIRECT = rt::O_DIRECT, NONBLOCK = rt::O_NONBLOCK, }; @@ -19,10 +19,11 @@ export type pipe_flag = enum { // recommended that you add it unless you know that you don't want it. export fn pipe(flags: pipe_flag...) ((io::file, io::file) | errors::error) = { let fds: [2]int = [0...]; - let flag: pipe_flag = if (len(flags) == 0) pipe_flag::CLOEXEC else 0; + let flag: pipe_flag = 0; for (let i = 0z; i < len(flags); i += 1) { flag |= flags[i]; }; + flag ^= pipe_flag::NOCLOEXEC; // invert CLOEXEC match (rt::pipe2(&fds, flag)) { case void => void; case let e: rt::errno => diff --git a/unix/+linux/pipe.ha b/unix/+linux/pipe.ha @@ -5,9 +5,9 @@ use io; use rt; // Flags to use for the [[io::file]]s returned by [[pipe]] -// Only CLOEXEC and NONBLOCK are guaranteed to be available. +// Only NOCLOEXEC and NONBLOCK are guaranteed to be available. export type pipe_flag = enum { - CLOEXEC = rt::O_CLOEXEC, + NOCLOEXEC = rt::O_CLOEXEC, DIRECT = rt::O_DIRECT, NONBLOCK = rt::O_NONBLOCK, }; @@ -18,10 +18,11 @@ export type pipe_flag = enum { // recommended that you add it unless you know that you don't want it. export fn pipe(flags: pipe_flag...) ((io::file, io::file) | errors::error) = { let fds: [2]int = [0...]; - let flag: pipe_flag = if (len(flags) == 0) pipe_flag::CLOEXEC else 0; + let flag: pipe_flag = 0; for (let i = 0z; i < len(flags); i += 1) { flag |= flags[i]; }; + flag ^= pipe_flag::NOCLOEXEC; // invert CLOEXEC match (rt::pipe2(&fds, flag)) { case void => void; case let e: rt::errno =>