20 #include <ripple/basics/Sustain.h>
21 #include <ripple/basics/safe_cast.h>
22 #include <ripple/beast/core/CurrentThreadName.h>
23 #include <boost/format.hpp>
28 #include <sys/prctl.h>
29 #include <sys/types.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);
70 if (getppid() != pManager)
73 kill(pManager, SIGHUP);
74 return "Terminating monitor";
78 checkChild(pid_t pid,
int options)
82 if (waitpid(pChild, &i, options) == -1)
85 return kill(pChild, 0) == 0;
92 signal(SIGINT, stop_manager);
93 signal(SIGHUP, stop_manager);
94 signal(SIGUSR1, pass_signal);
95 signal(SIGUSR2, pass_signal);
101 for (
auto childCount = 1;; ++childCount)
116 return "Launching child " + cc;
121 sleep(sleepBeforeWaiting);
126 if (!checkChild(pChild, WNOHANG))
135 while (checkChild(pChild, 0))
136 sleep(sleepBetweenWaits);