27 #include <sys/types.h> 29 #include <glog/logging.h> 41 constexpr
int kSignal = SIGUSR1;
47 CHECK_ERR(sigemptyset(&sigs));
48 CHECK_ERR(sigaddset(&sigs, kSignal));
49 CHECK_ERR(sigprocmask(SIG_BLOCK, &sigs,
nullptr));
52 CHECK_ERR(kill(getppid(), SIGKILL));
55 CHECK_ERR(sigwait(&sigs, &sig));
56 CHECK_EQ(sig, kSignal);
59 CHECK_ERR(creat(file, 0600));
63 std::vector<std::string> args{
"/proc/self/exe",
"--child", file};
64 Subprocess proc(args, Subprocess::Options().parentDeathSignal(kSignal));
74 gflags::ParseCommandLineFlags(&argc, &argv,
true);
void runParent(const char *file)
void runChild(const char *file)
int main(int argc, char *argv[])
constexpr detail::Sig< Sig > const sig
DEFINE_bool(child, false,"")
folly::Function< void()> child
ProcessReturnCode poll(struct rusage *ru=nullptr)