From af2e7f194414da8929a4532a1abe4da3c288ccfb Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Fri, 13 Nov 2015 18:12:37 +0000 Subject: [PATCH] Minor cleanup: use C++-style cast and add some comments --- service.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/service.cc b/service.cc index 5fedffe..c4c16d2 100644 --- a/service.cc +++ b/service.cc @@ -265,13 +265,18 @@ bool ServiceRecord::start_ps_process() } +// TODO this can currently throw std::bad_alloc, fix that (in the worst case, +// return failure instead). bool ServiceRecord::start_ps_process(const std::vector &pargs) { // In general, you can't tell whether fork/exec is successful. We use a pipe to communicate // success/failure from the child to the parent. The pipe is set CLOEXEC so a successful // exec closes the pipe, and the parent sees EOF. If the exec is unsuccessful, the errno // is written to the pipe, and the parent can read it. - + + // TODO should NOT wait for the exec to succeed or fail here, as that could (when/if we allow + // running child processes with lower priority) result in priority inversion. + using std::vector; using std::string; @@ -323,7 +328,7 @@ bool ServiceRecord::start_ps_process(const std::vector &pargs) } args[progAndArgs.size()] = nullptr; - execvp(pname, (char ** const) args); + execvp(pname, const_cast(args)); // If we got here, the exec failed: int exec_status = errno; -- 2.25.1