hare

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

commit adb7e17e84750493de93f996b164089c71f01428
parent 01aaa1c2b5f5d91db545095b22b22f4d352fc83d
Author: Alexey Yerin <yyp@disroot.org>
Date:   Thu,  9 Jun 2022 22:25:27 +0300

os::exec: return process from fork()

Matches other functions, such as self()

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mos/exec/exec+freebsd.ha | 12+++++++-----
Mos/exec/exec+linux.ha | 12+++++++-----
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/os/exec/exec+freebsd.ha b/os/exec/exec+freebsd.ha @@ -10,14 +10,16 @@ use unix; export type platform_cmd = io::file; -// Forks the current process, returning the pid of the child (to the parent) and -// void (to the child), or an error. -export fn fork() (int | void | error) = { +// Forks the current process, returning the [[process]] of the child (to the +// parent) and void (to the child), or an error. +export fn fork() (process | void | error) = { match (rt::fork()) { case let err: rt::errno => return errors::errno(err); - case let i: (int | void) => - return i; + case let i: int => + return i: process; + case void => + return void; }; }; diff --git a/os/exec/exec+linux.ha b/os/exec/exec+linux.ha @@ -10,14 +10,16 @@ use unix; export type platform_cmd = io::file; -// Forks the current process, returning the pid of the child (to the parent) and -// void (to the child), or an error. -export fn fork() (int | void | error) = { +// Forks the current process, returning the [[process]] of the child (to the +// parent) and void (to the child), or an error. +export fn fork() (process | void | error) = { match (rt::fork()) { case let err: rt::errno => return errors::errno(err); - case let i: (int | void) => - return i; + case let i: int => + return i: process; + case void => + return void; }; };