hare

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

commit 1481cf2a473459597adeec3358d6c522343afbfe
parent fee8e8584c043e8d02ec2b7c50cfa4282c6dc66b
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Wed, 19 Jun 2024 16:49:21 +0200

os::exec: open /dev/null with RDWR flag on nullfd

Default is RDONLY which can cause problems, if the child process writes to it.

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mos/exec/+freebsd/exec.ha | 3++-
Mos/exec/+linux/exec.ha | 3++-
Mos/exec/+netbsd/exec.ha | 3++-
Mos/exec/+openbsd/exec.ha | 3++-
4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/os/exec/+freebsd/exec.ha b/os/exec/+freebsd/exec.ha @@ -2,6 +2,7 @@ // (c) Hare authors <https://harelang.org> use errors; +use fs; use io; use os; use rt; @@ -132,7 +133,7 @@ fn platform_exec(cmd: *command) error = { }; const devnull: io::file = if (need_devnull) { - yield os::open("/dev/null")!; + yield os::open("/dev/null", fs::flag::RDWR)!; } else -1; for (let file .. cmd.files) { diff --git a/os/exec/+linux/exec.ha b/os/exec/+linux/exec.ha @@ -2,6 +2,7 @@ // (c) Hare authors <https://harelang.org> use errors; +use fs; use io; use os; use rt; @@ -137,7 +138,7 @@ fn platform_exec(cmd: *command) error = { }; const devnull: io::file = if (need_devnull) { - yield os::open("/dev/null")!; + yield os::open("/dev/null", fs::flag::RDWR)!; } else -1; for (let file .. cmd.files) { diff --git a/os/exec/+netbsd/exec.ha b/os/exec/+netbsd/exec.ha @@ -2,6 +2,7 @@ // (c) Hare authors <https://harelang.org> use errors; +use fs; use io; use os; use rt; @@ -132,7 +133,7 @@ fn platform_exec(cmd: *command) error = { }; const devnull: io::file = if (need_devnull) { - yield os::open("/dev/null")!; + yield os::open("/dev/null", fs::flag::RDWR)!; } else -1; for (let file .. cmd.files) { diff --git a/os/exec/+openbsd/exec.ha b/os/exec/+openbsd/exec.ha @@ -2,6 +2,7 @@ // (c) Hare authors <https://harelang.org> use errors; +use fs; use io; use os; use rt; @@ -107,7 +108,7 @@ fn platform_exec(cmd: *command) error = { }; const devnull: io::file = if (need_devnull) { - yield os::open("/dev/null")!; + yield os::open("/dev/null", fs::flag::RDWR)!; } else -1; for (let file .. cmd.files) {