hare

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

commit 395d2a35ce07004d9a44a6f02f285ff06415753c
parent b8f5350b97bdb7a3dbf6c8f3ee030ac1e2b939d8
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 14 Feb 2024 13:51:40 +0100

unix::tty: add tcsetpgrp

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mmakefiles/freebsd.aarch64.mk | 4++--
Mmakefiles/freebsd.riscv64.mk | 4++--
Mmakefiles/freebsd.x86_64.mk | 4++--
Mmakefiles/linux.aarch64.mk | 4++--
Mmakefiles/linux.riscv64.mk | 4++--
Mmakefiles/linux.x86_64.mk | 4++--
Mmakefiles/openbsd.aarch64.mk | 4++--
Mmakefiles/openbsd.riscv64.mk | 4++--
Mmakefiles/openbsd.x86_64.mk | 4++--
Mrt/+freebsd/types.ha | 1+
Aunix/tty/+freebsd/pgid.ha | 16++++++++++++++++
Aunix/tty/+linux/pgid.ha | 16++++++++++++++++
Aunix/tty/+openbsd/pgid.ha | 16++++++++++++++++
13 files changed, 67 insertions(+), 18 deletions(-)

diff --git a/makefiles/freebsd.aarch64.mk b/makefiles/freebsd.aarch64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pgid.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/freebsd.riscv64.mk b/makefiles/freebsd.riscv64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pgid.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/freebsd.x86_64.mk b/makefiles/freebsd.x86_64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+freebsd/isatty.ha unix/tty/+freebsd/open.ha unix/tty/+freebsd/pgid.ha unix/tty/+freebsd/pty.ha unix/tty/+freebsd/termios.ha unix/tty/+freebsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/linux.aarch64.mk b/makefiles/linux.aarch64.mk @@ -243,8 +243,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td +unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pgid.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/linux.riscv64.mk b/makefiles/linux.riscv64.mk @@ -243,8 +243,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td +unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pgid.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/linux.x86_64.mk b/makefiles/linux.x86_64.mk @@ -243,8 +243,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td +unix_tty_ha = unix/tty/+linux/isatty.ha unix/tty/+linux/open.ha unix/tty/+linux/pgid.ha unix/tty/+linux/pty.ha unix/tty/+linux/termios.ha unix/tty/+linux/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/openbsd.aarch64.mk b/makefiles/openbsd.aarch64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pgid.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/openbsd.riscv64.mk b/makefiles/openbsd.riscv64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pgid.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/makefiles/openbsd.x86_64.mk b/makefiles/openbsd.x86_64.mk @@ -225,8 +225,8 @@ $(HARECACHE)/shlex.ssa: $(shlex_ha) $(HARECACHE)/ascii.td $(HARECACHE)/encoding_ @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/shlex.ssa -t $(HARECACHE)/shlex.td.tmp -N shlex $(shlex_ha) -unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha -$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td +unix_tty_ha = unix/tty/+openbsd/isatty.ha unix/tty/+openbsd/open.ha unix/tty/+openbsd/pgid.ha unix/tty/+openbsd/pty.ha unix/tty/+openbsd/termios.ha unix/tty/+openbsd/winsize.ha unix/tty/pty_test.ha unix/tty/types.ha +$(HARECACHE)/unix_tty.ssa: $(unix_tty_ha) $(HARECACHE)/bufio.td $(HARECACHE)/errors.td $(HARECACHE)/fmt.td $(HARECACHE)/fs.td $(HARECACHE)/io.td $(HARECACHE)/os.td $(HARECACHE)/os_exec.td $(HARECACHE)/rt.td $(HARECACHE)/strings.td $(HARECACHE)/types_c.td @mkdir -p -- "$(HARECACHE)" @printf 'HAREC\t%s\n' "$@" @$(TDENV) $(HAREC) $(HARECFLAGS) -o $(HARECACHE)/unix_tty.ssa -t $(HARECACHE)/unix_tty.td.tmp -N unix::tty $(unix_tty_ha) diff --git a/rt/+freebsd/types.ha b/rt/+freebsd/types.ha @@ -251,6 +251,7 @@ export def TIOCSWINSZ: u64 = 0x80087467; export def TIOCGETA: u64 = 0x402c7413; export def TIOCSETA: u64 = 0x802c7414; export def TIOCPTMASTER: u64 = 0x2000741c; +export def TIOCSPGRP: u64 = 0x80047476; export def FIODGNAME: u64 = 0x80106678; export type rusage = struct { diff --git a/unix/tty/+freebsd/pgid.ha b/unix/tty/+freebsd/pgid.ha @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MPL-2.0 +// (c) Hare authors <https://harelang.org> + +use errors; +use io; +use os::exec; +use rt; + +// Sets the process group on the foreground of this terminal. +export fn tcsetpgrp(fd: io::file, pg: exec::process) (void | errors::error) = { + match (rt::ioctl(fd, rt::TIOCSPGRP, pg: u64)) { + case int => void; + case let err: rt::errno => + return errors::errno(err); + }; +}; diff --git a/unix/tty/+linux/pgid.ha b/unix/tty/+linux/pgid.ha @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MPL-2.0 +// (c) Hare authors <https://harelang.org> + +use errors; +use io; +use os::exec; +use rt; + +// Sets the process group on the foreground of this terminal. +export fn tcsetpgrp(fd: io::file, pg: exec::process) (void | errors::error) = { + match (rt::ioctl(fd, rt::TIOCSPGRP, pg: u64)) { + case int => void; + case let err: rt::errno => + return errors::errno(err); + }; +}; diff --git a/unix/tty/+openbsd/pgid.ha b/unix/tty/+openbsd/pgid.ha @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MPL-2.0 +// (c) Hare authors <https://harelang.org> + +use errors; +use io; +use os::exec; +use rt; + +// Sets the process group on the foreground of this terminal. +export fn tcsetpgrp(fd: io::file, pg: exec::process) (void | errors::error) = { + match (rt::ioctl(fd, rt::TIOCSPGRP, pg: u64)) { + case int => void; + case let err: rt::errno => + return errors::errno(err); + }; +};