20 #include <ripple/basics/safe_cast.h>
21 #include <ripple/basics/Sustain.h>
22 #include <ripple/beast/core/CurrentThreadName.h>
23 #include <boost/format.hpp>
28 #include <sys/types.h>
29 #include <sys/prctl.h>
34 #include <sys/types.h>
42 static auto const sleepBeforeWaiting = 10;
43 static auto const sleepBetweenWaits = 1;
45 static pid_t pManager = safe_cast<pid_t> (0);
46 static pid_t pChild = safe_cast<pid_t> (0);
48 static void pass_signal (
int a)
53 static void stop_manager (
int)
55 kill (pChild, SIGINT);
66 if (getppid () != pManager)
69 kill (pManager, SIGHUP);
70 return "Terminating monitor";
74 bool checkChild(pid_t pid,
int options)
78 if (waitpid (pChild, &i, options) == -1)
81 return kill (pChild, 0) == 0;
87 signal (SIGINT, stop_manager);
88 signal (SIGHUP, stop_manager);
89 signal (SIGUSR1, pass_signal);
90 signal (SIGUSR2, pass_signal);
96 for (
auto childCount = 1; ; ++childCount)
109 signal (SIGUSR1, SIG_DFL);
110 signal (SIGUSR2, SIG_DFL);
111 return "Launching child " + cc;
116 sleep (sleepBeforeWaiting);
121 if (!checkChild (pChild, WNOHANG))
130 while (checkChild (pChild, 0))
131 sleep(sleepBetweenWaits);
133 (void)rename (
"core",