mirror of
https://github.com/pikvm/ustreamer.git
synced 2025-12-23 18:50:00 +00:00
manual WITH_PDEATHSIG
This commit is contained in:
parent
f3e0613de3
commit
b2d1a5612d
1
Makefile
1
Makefile
@ -22,6 +22,7 @@ WITH_GPIO ?= 0
|
||||
WITH_SYSTEMD ?= 0
|
||||
WITH_PTHREAD_NP ?= 1
|
||||
WITH_SETPROCTITLE ?= 1
|
||||
WITH_PDEATHSIG ?= 1
|
||||
|
||||
export
|
||||
|
||||
|
||||
@ -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).
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -25,14 +25,8 @@
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#if defined(__linux__)
|
||||
# define HAS_PDEATHSIG
|
||||
#elif defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/param.h>
|
||||
# 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 <sys/prctl.h>
|
||||
# elif defined(__FreeBSD__)
|
||||
# elif defined(__FreeBSD__) && (__FreeBSD_version >= 1102000)
|
||||
# include <sys/procctl.h>
|
||||
# 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;
|
||||
|
||||
@ -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 <pin> ──── Set 1 while streaming. Default: disabled.\n");
|
||||
SAY(" --gpio-has-http-clients <pin> ─ 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 <sec> ──── Exit the program if there have been no stream or sink clients");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user