diff --git a/Makefile b/Makefile index 4b438c9..5c26903 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ WITH_GPIO ?= 0 WITH_SYSTEMD ?= 0 WITH_PTHREAD_NP ?= 1 WITH_SETPROCTITLE ?= 1 +WITH_PDEATHSIG ?= 1 export diff --git a/man/ustreamer.1 b/man/ustreamer.1 index 21f7640..10312e3 100644 --- a/man/ustreamer.1 +++ b/man/ustreamer.1 @@ -274,7 +274,7 @@ Timeout for lock. Default: 1. .SS "Process options" .TP .BR \-\-exit\-on\-parent\-death -Exit the program if the parent process is dead. Required \fBHAS_PDEATHSIG\fR feature. Default: disabled. +Exit the program if the parent process is dead. Required \fBWITH_PDEATHSIG\fR feature. Default: disabled. .TP .BR \-\-exit\-on\-no\-clients \fIsec Exit the program if there have been no stream or sink clients or any HTTP requests in the last N seconds. Default: 0 (disabled). diff --git a/src/Makefile b/src/Makefile index 1c1d4da..e15932e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -73,6 +73,10 @@ override _USTR_LDFLAGS += -lbsd endif endif +ifneq ($(call optbool,$(WITH_PDEATHSIG)),) +override _CFLAGS += -DWITH_PDEATHSIG +endif + ifneq ($(call optbool,$(WITH_V4P)),) override _TARGETS += $(_V4P) override _OBJS += $(_V4P_SRCS:%.c=$(_BUILD)/%.o) diff --git a/src/libs/process.h b/src/libs/process.h index 4c0bdd7..edd0c09 100644 --- a/src/libs/process.h +++ b/src/libs/process.h @@ -25,14 +25,8 @@ #include #include - -#if defined(__linux__) -# define HAS_PDEATHSIG -#elif defined(__FreeBSD__) +#if defined(__FreeBSD__) # include -# if __FreeBSD_version >= 1102000 -# define HAS_PDEATHSIG -# endif #endif @@ -49,20 +43,22 @@ # error setproctitle() not implemented, you can disable it using WITH_SETPROCTITLE=0 # endif #endif -#ifdef HAS_PDEATHSIG + +#ifdef WITH_PDEATHSIG # if defined(__linux__) # include -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) && (__FreeBSD_version >= 1102000) # include +# else +# error WITH_PDEATHSIG is not supported on your system # endif #endif + #include "types.h" #ifdef WITH_SETPROCTITLE # include "tools.h" #endif -#ifdef HAS_PDEATHSIG -# include "logging.h" -#endif +#include "logging.h" #ifdef WITH_SETPROCTITLE @@ -70,7 +66,7 @@ extern char **environ; #endif -#ifdef HAS_PDEATHSIG +#ifdef WITH_PDEATHSIG INLINE int us_process_track_parent_death(void) { const pid_t parent = getppid(); int signum = SIGTERM; diff --git a/src/ustreamer/options.c b/src/ustreamer/options.c index cbd7347..1e54937 100644 --- a/src/ustreamer/options.c +++ b/src/ustreamer/options.c @@ -114,7 +114,7 @@ enum _US_OPT_VALUES { _O_GPIO_HAS_HTTP_CLIENTS, # endif -# ifdef HAS_PDEATHSIG +# ifdef WITH_PDEATHSIG _O_EXIT_ON_PARENT_DEATH, # endif _O_EXIT_ON_NO_CLIENTS, @@ -224,7 +224,7 @@ static const struct option _LONG_OPTS[] = { {"gpio-has-http-clients", required_argument, NULL, _O_GPIO_HAS_HTTP_CLIENTS}, # endif -# ifdef HAS_PDEATHSIG +# ifdef WITH_PDEATHSIG {"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH}, # endif {"exit-on-no-clients", required_argument, NULL, _O_EXIT_ON_NO_CLIENTS}, @@ -483,7 +483,7 @@ int options_parse(us_options_s *options, us_capture_s *cap, us_encoder_s *enc, u case _O_GPIO_HAS_HTTP_CLIENTS: OPT_NUMBER("--gpio-has-http-clients", us_g_gpio.has_http_clients.pin, 0, 256, 0); # endif -# ifdef HAS_PDEATHSIG +# ifdef WITH_PDEATHSIG case _O_EXIT_ON_PARENT_DEATH: if (us_process_track_parent_death() < 0) { return -1; @@ -611,10 +611,10 @@ static void _features(void) { puts("- WITH_SETPROCTITLE"); # endif -# ifdef HAS_PDEATHSIG - puts("+ HAS_PDEATHSIG"); +# ifdef WITH_PDEATHSIG + puts("+ WITH_PDEATHSIG"); # else - puts("- HAS_PDEATHSIG"); + puts("- WITH_PDEATHSIG"); # endif } @@ -746,11 +746,11 @@ static void _help(FILE *fp, const us_capture_s *cap, const us_encoder_s *enc, co SAY(" --gpio-stream-online ──── Set 1 while streaming. Default: disabled.\n"); SAY(" --gpio-has-http-clients ─ Set 1 while stream has at least one client. Default: disabled.\n"); # endif -# if (defined(HAS_PDEATHSIG) || defined(WITH_SETPROCTITLE)) +# if (defined(WITH_PDEATHSIG) || defined(WITH_SETPROCTITLE)) SAY("Process options:"); SAY("════════════════"); # endif -# ifdef HAS_PDEATHSIG +# ifdef WITH_PDEATHSIG SAY(" --exit-on-parent-death ─────── Exit the program if the parent process is dead. Default: disabled.\n"); # endif SAY(" --exit-on-no-clients ──── Exit the program if there have been no stream or sink clients");