slweb

Једноставни генератор статичких веб страна
git clone https://git.sr.ht/~strahinja/slweb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 9aa6d4b88f69fb2e54c4a3791ba8a568f41f9724
родитељ 105d12a6f3281f5a01fb68d8c6d043d4a8c57ba2
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Tue, 20 Feb 2024 13:32:53 +0100

Add workaround for no prctl under OpenBSDgned-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MTODO | 4+++-
Mdefs.h | 7+++++++
Mslweb.c | 8++++++++
измењених датотека: 3, додавања: 18(+), брисања: 1(-)

diff --git a/TODO b/TODO @@ -1,7 +1,9 @@ TODO ==== -[ ] Critical: There is no sys/prctl.h in OpenBSD? +[~] Critical: There is no sys/prctl.h in OpenBSD? + [x] Immediate bandaid solution (missing functionality under OpenBSD) + [ ] Real solution (children die with parent) < > Add <abbr>? diff --git a/defs.h b/defs.h @@ -8,12 +8,19 @@ #include <ctype.h> #include <dirent.h> #include <errno.h> +#include <signal.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> +#ifdef __OpenBSD__ +/* TODO: Add any necessary headers for the equivalent of prctl */ +#elif __linux__ #include <sys/prctl.h> +#else +#error Unsupported OS! Patches welcome... +#endif #include <sys/stat.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/slweb.c b/slweb.c @@ -418,7 +418,11 @@ print_command(FILE* output, const char* command, const u8* pass_arguments[], close(arg_pipe_fds[PIPE_WRITE_INDEX]); close(output_pipe_fds[PIPE_READ_INDEX]); +#ifdef __OpenBSD__ +/* TODO: Add the equivalent of prctl... */ +#elif __linux__ prctl(PR_SET_PDEATHSIG, SIGTERM); +#endif dup2(arg_pipe_fds[PIPE_READ_INDEX], STDIN_FILENO); dup2(output_pipe_fds[PIPE_WRITE_INDEX], STDOUT_FILENO); @@ -1402,7 +1406,11 @@ process_include(FILE* output, const u8* token, int result = 0; FILE* child_output = NULL; +#ifdef __OpenBSD__ +/* TODO: Add the equivalent of prctl... */ +#elif __linux__ prctl(PR_SET_PDEATHSIG, SIGTERM); +#endif close(arg_pipe_fds[PIPE_WRITE_INDEX]); close(output_pipe_fds[PIPE_READ_INDEX]); if (!(child_output