aboutsummaryrefslogtreecommitdiff
path: root/src/safe.c
diff options
context:
space:
mode:
authorMosder <git@mosder.eu>2026-09-17 12:37:01 +0200
committerMosder <git@mosder.eu>2026-09-17 12:37:11 +0200
commitde163fe7ee64e63d36dd581db16c776831cbead0 (patch)
tree57f9861bd63a5479c8ee1d829a00d3b4ab053bba /src/safe.c
parent33e2e9d8aff7ee16aa5c071df93d6f9c0a37e53f (diff)
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
Diffstat (limited to 'src/safe.c')
-rw-r--r--src/safe.c16
1 files changed, 16 insertions, 0 deletions
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);
+}