From caa7b2fcc8e9518f4b6ab0d5d7b3adfac1068415 Mon Sep 17 00:00:00 2001 From: Klemens David Morgenstern Date: Wed, 8 May 2019 16:28:54 +0700 Subject: [PATCH 1/3] two minor fixes --- doc/concepts.qbk | 2 +- include/boost/process/detail/posix/pipe_out.hpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/concepts.qbk b/doc/concepts.qbk index 06658a45..afc5485b 100644 --- a/doc/concepts.qbk +++ b/doc/concepts.qbk @@ -16,7 +16,7 @@ In that it is different than other facilities (like sockets) and provides anothe Pipes are typically used for interprocess communication. The main reason is, that pipes can be directly assigned to the process stdio, i.e. stderr, stdin and stdout. Additionally, half of the pipe can be inherited to the child process and closed in the father process. This will cause the pipe to be broken when the child process exits. -Though please not, that if the the same thread reads and write to a pipe, it will only talk to itself. +Though please note, that if the the same thread reads and write to a pipe, it will only talk to itself. [section:anonymous Anonymous Pipes] diff --git a/include/boost/process/detail/posix/pipe_out.hpp b/include/boost/process/detail/posix/pipe_out.hpp index 9f7da946..d54cca4e 100644 --- a/include/boost/process/detail/posix/pipe_out.hpp +++ b/include/boost/process/detail/posix/pipe_out.hpp @@ -52,8 +52,10 @@ template void pipe_out<1,-1>::on_exec_setup(Executor &e) const { if (::dup2(sink, STDOUT_FILENO) == -1) - e.set_error(::boost::process::detail::get_last_error(), "dup3() failed"); - ::close(sink); + e.set_error(::boost::process::detail::get_last_error(), "dup2() failed"); + + if (sink != STDOUT_FILENO) + ::close(sink); ::close(source); } @@ -63,7 +65,9 @@ void pipe_out<2,-1>::on_exec_setup(Executor &e) const { if (::dup2(sink, STDERR_FILENO) == -1) e.set_error(::boost::process::detail::get_last_error(), "dup2() failed"); - ::close(sink); + + if (sink != STDOUT_FILENO) + ::close(sink); ::close(source); } @@ -75,8 +79,8 @@ void pipe_out<1,2>::on_exec_setup(Executor &e) const e.set_error(::boost::process::detail::get_last_error(), "dup2() failed"); if (::dup2(sink, STDERR_FILENO) == -1) e.set_error(::boost::process::detail::get_last_error(), "dup2() failed"); - ::close(sink); - ::close(source); + if ((sink != STDOUT_FILENO) && (sink != STDERR_FILENO)) + ::close(sink); } class async_pipe; From 66c28673711a34a44923bde3e7a8a3ddafd1f12f Mon Sep 17 00:00:00 2001 From: Klemens David Morgenstern Date: Wed, 8 May 2019 16:30:39 +0700 Subject: [PATCH 2/3] removed travis token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 281208d3..cffbdb52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -133,6 +133,6 @@ after_success: - coveralls-lcov coverals/coverage.info after_script: - - curl -s https://report.ci/upload.py | python - --token=$REPORT_CI_TOKEN --name="$BADGE test run" + - curl -s https://report.ci/upload.py | python - --name="$BADGE test run" - bash <(curl -s https://codecov.io/bash) From 417ea77f2f611e2934e65deb4b1e7cafdc53a568 Mon Sep 17 00:00:00 2001 From: Klemens David Morgenstern Date: Wed, 8 May 2019 16:50:49 +0700 Subject: [PATCH 3/3] changed SIGTERM to SIGKILL --- .circleci/config.yml | 1 + include/boost/process/detail/posix/wait_for_exit.hpp | 2 +- include/boost/process/detail/posix/wait_group.hpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 163df8d6..a7fc66a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,6 +70,7 @@ jobs: python <(curl -s https://report.ci/annotate.py) --tool gcc --input test.log python <(curl -s https://report.ci/annotate.py) --tool gcc --input no-valgrind.log + cd ../../.. python <(curl -s https://report.ci/upload.py) --name "Circle CI Gcc Tests" --framework boost bash <(curl -s https://codecov.io/bash) -x gcov || true echo "BUILD_RESULT: $FAILED" diff --git a/include/boost/process/detail/posix/wait_for_exit.hpp b/include/boost/process/detail/posix/wait_for_exit.hpp index 16fbacfc..faa26f19 100644 --- a/include/boost/process/detail/posix/wait_for_exit.hpp +++ b/include/boost/process/detail/posix/wait_for_exit.hpp @@ -125,7 +125,7 @@ inline bool wait_until( ~child_cleaner_t() { int res; - ::kill(pid, SIGTERM); + ::kill(pid, SIGKILL); ::waitpid(pid, &res, WNOHANG); } }; diff --git a/include/boost/process/detail/posix/wait_group.hpp b/include/boost/process/detail/posix/wait_group.hpp index fc6870d0..12c73a5d 100644 --- a/include/boost/process/detail/posix/wait_group.hpp +++ b/include/boost/process/detail/posix/wait_group.hpp @@ -129,7 +129,7 @@ inline bool wait_until( ~child_cleaner_t() { int res; - ::kill(pid, SIGTERM); + ::kill(pid, SIGKILL); ::waitpid(pid, &res, WNOHANG); } };