1 #include "mem_config.h"
11 # define SET_ENV(n, k, v) setenv(k, v, 0)
13 # define SET_ENV(n, k, v) static char n ## _env[] = k "=" v; putenv(n ## _env)
16 static void sigchld(int, siginfo_t
*si
, void *) {
17 switch (si
->si_code
) {
22 if (si
->si_status
== SIGKILL
) {
28 std::cerr
<< "Server{pid="
29 << std::to_string(si
->si_pid
)
31 << strsignal(si
->si_status
)
37 static inline void setup_signals() {
40 memset(&sa
, 0, sizeof(sa
));
41 sa
.sa_flags
= SA_NOCLDSTOP
| SA_RESTART
| SA_SIGINFO
| SA_NODEFER
;
43 sa
.sa_sigaction
= sigchld
;
44 if (0 > sigaction(SIGCHLD
, &sa
, nullptr)) {
45 perror("sigaction(CHLD)");
50 // this has to be a macro for putenv() to work
51 # define ASAN_OPTIONS \
52 "check_initialization_order=1," \
55 "detect_stack_use_after_return=1," \
56 "alloc_dealloc_mismatch=1," \
57 "new_delete_type_mismatch=1," \
58 "detect_odr_violation=2," \
60 "verify_asan_link_order=1," \
63 static inline void setup_asan(char **argv
) {
64 const auto set
= getenv("ASAN_OPTIONS");
67 SET_ENV(asan
, "ASAN_OPTIONS", ASAN_OPTIONS
);
68 execvp(argv
[0], argv
);
73 # define setup_asan(a)
76 #if LIBMEMCACHED_WITH_SASL_SUPPORT
77 static inline void setup_sasl() {
78 SET_ENV(sasl_pwdb
, "MEMCACHED_SASL_PWDB", LIBMEMCACHED_WITH_SASL_PWDB
);
79 SET_ENV(sasl_conf
, "SASL_CONF_PATH", LIBMEMCACHED_WITH_SASL_CONF
);
85 int setup(int &, char ***argv
) {