mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-27 12:16:31 +00:00
refactoring
This commit is contained in:
@@ -108,7 +108,7 @@ enum _OPT_VALUES {
|
||||
_O_GPIO_WORKERS_BUSY_AT,
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
#ifdef HAS_PDEATHSIG
|
||||
_O_EXIT_ON_PARENT_DEATH,
|
||||
#endif
|
||||
|
||||
@@ -176,7 +176,7 @@ static const struct option _LONG_OPTS[] = {
|
||||
{"gpio-workers-busy-at", required_argument, NULL, _O_GPIO_WORKERS_BUSY_AT},
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
#ifdef HAS_PDEATHSIG
|
||||
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
|
||||
#endif
|
||||
|
||||
@@ -342,8 +342,8 @@ int parse_options(int argc, char *argv[], struct device_t *dev, struct encoder_t
|
||||
case _O_GPIO_WORKERS_BUSY_AT: OPT_NUMBER("--gpio-workers-busy-at", gpio_pin_workers_busy_at, 0, 256, 0);
|
||||
# endif
|
||||
|
||||
# ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
case _O_EXIT_ON_PARENT_DEATH: process_set_sigterm_on_parent_death(); break;
|
||||
# ifdef HAS_PDEATHSIG
|
||||
case _O_EXIT_ON_PARENT_DEATH: process_set_pdeathsig_sigterm(); break;
|
||||
# endif
|
||||
|
||||
case _O_LOG_LEVEL: OPT_NUMBER("--log-level", log_level, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, 0);
|
||||
@@ -552,7 +552,7 @@ static void _help(struct device_t *dev, struct encoder_t *encoder, struct http_s
|
||||
printf(" --gpio-workers-busy-at <pin> ── Set 1 on (pin + N) while worker with number N has a job.\n");
|
||||
printf(" The worker's numbering starts from 0. Default: disabled\n\n");
|
||||
#endif
|
||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
#ifdef HAS_PDEATHSIG
|
||||
printf("Process options:\n");
|
||||
printf("════════════════\n");
|
||||
printf(" --exit-on-parent-death ─ Exit the program if the parent process is dead. Default: disabled.\n\n");
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__linux__)
|
||||
# define HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
# define HAS_PDEATHSIG
|
||||
#elif defined(__FreeBSD__)
|
||||
# include <sys/param.h>
|
||||
# if __FreeBSD_version >= 1102000
|
||||
# define HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
# define HAS_PDEATHSIG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
||||
#ifdef HAS_PDEATHSIG
|
||||
# include <signal.h>
|
||||
|
||||
# if defined(__linux__)
|
||||
@@ -42,8 +42,7 @@
|
||||
|
||||
# include "logging.h"
|
||||
|
||||
|
||||
INLINE void process_set_sigterm_on_parent_death(void) {
|
||||
INLINE void process_set_pdeathsig_sigterm(void) {
|
||||
int signum = SIGTERM;
|
||||
# ifdef __linux__
|
||||
int retval = prctl(PR_SET_PDEATHSIG, signum);
|
||||
@@ -57,4 +56,4 @@ INLINE void process_set_sigterm_on_parent_death(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // HAS_PDEATHSIG
|
||||
|
||||
Reference in New Issue
Block a user