mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-14 19:43:42 +00:00
refactoring
This commit is contained in:
@@ -108,7 +108,7 @@ enum _OPT_VALUES {
|
|||||||
_O_GPIO_WORKERS_BUSY_AT,
|
_O_GPIO_WORKERS_BUSY_AT,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
#ifdef HAS_PDEATHSIG
|
||||||
_O_EXIT_ON_PARENT_DEATH,
|
_O_EXIT_ON_PARENT_DEATH,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ static const struct option _LONG_OPTS[] = {
|
|||||||
{"gpio-workers-busy-at", required_argument, NULL, _O_GPIO_WORKERS_BUSY_AT},
|
{"gpio-workers-busy-at", required_argument, NULL, _O_GPIO_WORKERS_BUSY_AT},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
#ifdef HAS_PDEATHSIG
|
||||||
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
|
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
|
||||||
#endif
|
#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);
|
case _O_GPIO_WORKERS_BUSY_AT: OPT_NUMBER("--gpio-workers-busy-at", gpio_pin_workers_busy_at, 0, 256, 0);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
# ifdef HAS_PDEATHSIG
|
||||||
case _O_EXIT_ON_PARENT_DEATH: process_set_sigterm_on_parent_death(); break;
|
case _O_EXIT_ON_PARENT_DEATH: process_set_pdeathsig_sigterm(); break;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
case _O_LOG_LEVEL: OPT_NUMBER("--log-level", log_level, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, 0);
|
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(" --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");
|
printf(" The worker's numbering starts from 0. Default: disabled\n\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
#ifdef HAS_PDEATHSIG
|
||||||
printf("Process options:\n");
|
printf("Process options:\n");
|
||||||
printf("════════════════\n");
|
printf("════════════════\n");
|
||||||
printf(" --exit-on-parent-death ─ Exit the program if the parent process is dead. Default: disabled.\n\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
|
#pragma once
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
# define HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
# define HAS_PDEATHSIG
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
# include <sys/param.h>
|
# include <sys/param.h>
|
||||||
# if __FreeBSD_version >= 1102000
|
# if __FreeBSD_version >= 1102000
|
||||||
# define HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
# define HAS_PDEATHSIG
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PROCESS_SET_SIGTERM_ON_PARENT_DEATH
|
#ifdef HAS_PDEATHSIG
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
|
|
||||||
# if defined(__linux__)
|
# if defined(__linux__)
|
||||||
@@ -42,8 +42,7 @@
|
|||||||
|
|
||||||
# include "logging.h"
|
# include "logging.h"
|
||||||
|
|
||||||
|
INLINE void process_set_pdeathsig_sigterm(void) {
|
||||||
INLINE void process_set_sigterm_on_parent_death(void) {
|
|
||||||
int signum = SIGTERM;
|
int signum = SIGTERM;
|
||||||
# ifdef __linux__
|
# ifdef __linux__
|
||||||
int retval = prctl(PR_SET_PDEATHSIG, signum);
|
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