From de163fe7ee64e63d36dd581db16c776831cbead0 Mon Sep 17 00:00:00 2001 From: Mosder Date: Thu, 17 Sep 2026 12:37:01 +0200 Subject: feat: improved compatibility - removed possible duplicate names, exit tests now create a fork instead of relying on being able to overwrite exit function, made tester only output ASCII escape sequences for colour into a tty --- src/safe.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/safe.c') diff --git a/src/safe.c b/src/safe.c index 1b75bf2..fd7a1af 100644 --- a/src/safe.c +++ b/src/safe.c @@ -72,3 +72,19 @@ int mos_safe_dup2_fn(int fd, int fd2, MosSafeErrInfo info) { ERR_MESS("failed to dup %d 2 %d", fd, fd2); exit(EXIT_FAILURE); } + +pid_t mos_safe_fork_fn(MosSafeErrInfo info) { + pid_t pid = fork(); + if (pid != -1) + return pid; + ERR_MESS("failed to fork"); + exit(EXIT_FAILURE); +} + +int mos_safe_pipe_fn(int fd[2], MosSafeErrInfo info) { + int res = pipe(fd); + if (res != -1) + return res; + ERR_MESS("failed to pipe"); + exit(EXIT_FAILURE); +} -- cgit v1.2.3