Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
89d2cc3
Update index.html
klemens-morgenstern Apr 11, 2025
a941c8e
Add BOOST_PROCESS_USE_STD_FS option
yurybura Apr 11, 2025
1d6c9ed
Fix conflicting pipe name in independent plug-in DLLs
RK-BFX Apr 10, 2025
5756891
Fix wide strings conversion on POSIX
Osyotr Apr 9, 2025
9dcd1a2
added duplication check for SIGINFO
klemens-morgenstern Apr 14, 2025
afdbab7
Removed char_count
klemens-morgenstern Apr 14, 2025
da08060
Set ENOTSUP when PROC_PPID_ONLY is undefined
klemens-morgenstern Jan 26, 2025
7e71298
added BOOST_PROCESS_V2_PIPEFORK option
klemens-morgenstern Dec 20, 2024
06595a2
added BOOST_PROCESS_V2_DISABLE_SIGNALSET option
klemens-morgenstern Dec 20, 2024
1baccf7
pipe bindings use a type_trait.
klemens-morgenstern Apr 14, 2025
cd1621b
fixed major resume/suspend typo
klemens-morgenstern Apr 28, 2025
0694601
Remove Ubuntu 20.04 builds from CI
striezel May 3, 2025
818e116
Fix build on systems without cmd() implementation
petterreinholdtsen May 4, 2025
09555da
Add cmd & env support on GNU/Hurd
petterreinholdtsen May 4, 2025
15555b9
Fix some typos
striezel May 3, 2025
b8b8d27
fix STD_INPUT_HANDLE issue in stdio.hpp
klemens-morgenstern Jun 20, 2025
677d94f
Correct Samuel Venable Link In Acknowledgements Document
samuelvenable May 17, 2025
0ea2eae
Support child_pids() Even When PROC_PPID_ONLY is Undefined on Mac
samuelvenable May 17, 2025
3999fac
unused variable fixes.
klemens-morgenstern Jun 20, 2025
921bd59
Fixed wrong type in probe_on_error on windows.
klemens-morgenstern May 24, 2025
f372a9a
fixed MultiByteToWideChar use for empty strings
klemens-morgenstern Jun 20, 2025
f9fd327
added const_iterator alias to current_view.
klemens-morgenstern Jun 20, 2025
a7e4fe9
stdio.hpp name fix.
klemens-morgenstern Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ jobs:
include:
- { toolset: gcc-5, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-5 }
- { toolset: gcc-6, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-6 }
- { toolset: gcc-7, cxxstd: "11,14,17", os: ubuntu-20.04, install: g++-7 }
- { toolset: gcc-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: g++-7 }
- { toolset: gcc-10, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: g++-10 }
- { toolset: gcc-12, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: g++-12 }
- { toolset: clang, compiler: clang++-3.9, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-3.9 }
- { toolset: clang, compiler: clang++-4.0, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-4.0 }
- { toolset: clang, compiler: clang++-5.0, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-5.0 }
- { toolset: clang, compiler: clang++-6.0, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-6.0 }
- { toolset: clang, compiler: clang++-7, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-7 }
- { toolset: clang, compiler: clang++-8, cxxstd: "11,14,17", os: ubuntu-20.04, install: clang-8 }
- { toolset: clang, compiler: clang++-9, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-9 }
- { toolset: clang, compiler: clang++-10, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-10 }
- { toolset: clang, compiler: clang++-11, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-11 }
- { toolset: clang, compiler: clang++-12, cxxstd: "11,14,17,2a", os: ubuntu-20.04, install: clang-12 }
- { toolset: clang, compiler: clang++-6.0, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-6.0 }
- { toolset: clang, compiler: clang++-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-7 }
- { toolset: clang, compiler: clang++-8, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-8 }
- { toolset: clang, compiler: clang++-9, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-9 }
- { toolset: clang, compiler: clang++-10, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-10 }
- { toolset: clang, compiler: clang++-11, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-11 }
- { toolset: clang, compiler: clang++-12, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-12 }
- { toolset: clang, compiler: clang++-13, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-13 }
- { toolset: clang, compiler: clang++-14, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-14 }
- { toolset: clang, cxxstd: "11,14,17,2a", os: macos-13 }
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cmake_minimum_required(VERSION 3.5...3.16)

project(boost_process VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

option(BOOST_PROCESS_USE_STD_FS "Use std::filesystem instead of Boost.Filesystem" OFF)

add_library(boost_process
src/detail/environment_posix.cpp
src/detail/environment_win.cpp
Expand Down Expand Up @@ -49,13 +51,14 @@ target_compile_definitions(boost_process
PRIVATE BOOST_PROCESS_SOURCE=1
)

if (BOOST_PROCESS_USE_STD_FS)
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_USE_STD_FS=1 )
if(BOOST_PROCESS_USE_STD_FS)
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_USE_STD_FS)
target_compile_features(boost_process PUBLIC cxx_std_17)
else()
target_link_libraries(boost_process PUBLIC Boost::filesystem)
endif()

if (WIN32)
if(WIN32)
target_link_libraries(boost_process PUBLIC ntdll shell32 advapi32 user32 ws2_32)
endif()

Expand Down
2 changes: 1 addition & 1 deletion doc/acknowledgements.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ A special thank you goes to [http://www.intra2net.com/(Intra2net AG) (especially

Great thanks also goes to Boris Schaeling, who despite having boost.process rejected, went on to work on it and maintained it up until this day and participated in the development of the current version.

Many Thanks, to [https://github.com/time-killer-games](Samuel Venable) for contributing the <<v2::ext>> functionality and all the research that went into it.
Many Thanks, to [https://github.com/samuelvenable](Samuel Venable) for contributing the <<v2::ext>> functionality and all the research that went into it.


4 changes: 2 additions & 2 deletions doc/reference/environment.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

=== `environment`

The `environment` header provides facilities to maniuplate the current environment and set it for new processes.
The `environment` header provides facilities to manipulate the current environment and set it for new processes.


An environment is a a `range` of `T` fulfilling these requirements:
Expand All @@ -22,7 +22,7 @@ namespace environment
// A char traits type that reflects the OS rules for string representing environment keys.
/* Can be an alias of std::char_traits. May only be defined for `char` and `wchar_t`.
*
* Windows treats keys as case-insensitive yet perserving. The char traits are made to reflect
* Windows treats keys as case-insensitive yet preserving. The char traits are made to reflect
* that behaviour.
*/
template<typename Char>
Expand Down
2 changes: 1 addition & 1 deletion doc/version2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The major changes are
* separate compilation
* fd safe by default

Version 2 is now the defauled. In order to discourage usage of the deprecated v1, it's documentation has been removed.
Version 2 is now the default. In order to discourage usage of the deprecated v1, it's documentation has been removed.

== Simplified Interface

Expand Down
2 changes: 1 addition & 1 deletion include/boost/process/v1/async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ io_context ios;
child c("ls", ios, on_exit=[](int exit, const std::error_code& ec_in){});

std::future<int> exit_code;
chlid c2("ls", ios, on_exit=exit_code);
child c2("ls", ios, on_exit=exit_code);

\endcode

Expand Down
2 changes: 1 addition & 1 deletion include/boost/process/v1/async_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
#if defined(BOOST_PROCESS_DOXYGEN)


/** Class implementing an asnychronous I/O-Object for use with boost.asio.
/** Class implementing an asynchronous I/O-Object for use with boost.asio.
* It is based on the corresponding I/O Object, that is either boost::asio::windows::stream_handle or
* boost::asio::posix::stream_descriptor.
*
Expand Down
2 changes: 1 addition & 1 deletion include/boost/process/v1/child.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class child
/** Same as valid, for convenience. */
explicit operator bool() const;

/** Check if the the chlid process is in any process group. */
/** Check if the the child process is in any process group. */
bool in_group() const;

/** \overload bool in_group() const */
Expand Down
7 changes: 2 additions & 5 deletions include/boost/process/v1/detail/windows/async_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ inline std::string make_pipe_name()
static std::atomic_size_t cnt{0};
name += std::to_string(pid);
name += "_";
name += std::to_string(intptr_t(&cnt)); // to unclash Boost instances in plug-in DLLs
name += "_";
name += std::to_string(cnt++);

return name;
Expand Down Expand Up @@ -60,8 +62,6 @@ class async_pipe
async_pipe(boost::asio::io_context & ios_source, boost::asio::io_context & ios_sink, const std::string & name)
: async_pipe(ios_source, ios_sink, name, false) {}



inline async_pipe(const async_pipe& rhs);
async_pipe(async_pipe&& rhs) : _source(std::move(rhs._source)), _sink(std::move(rhs._sink))
{
Expand Down Expand Up @@ -153,7 +153,6 @@ class async_pipe
return _sink.write_some(buffers);
}


template<typename MutableBufferSequence>
std::size_t read_some(const MutableBufferSequence & buffers, boost::system::error_code & ec) noexcept
{
Expand Down Expand Up @@ -281,7 +280,6 @@ async_pipe::async_pipe(const async_pipe& p) :
_sink. assign(sink);
}


async_pipe::async_pipe(boost::asio::io_context & ios_source,
boost::asio::io_context & ios_sink,
const std::string & name, bool private_) : _source(ios_source), _sink(ios_sink)
Expand All @@ -298,7 +296,6 @@ async_pipe::async_pipe(boost::asio::io_context & ios_source,
| FILE_FLAG_OVERLAPPED_, //write flag
0, private_ ? 1 : ::boost::winapi::PIPE_UNLIMITED_INSTANCES_, 8192, 8192, 0, nullptr);


if (source == boost::winapi::INVALID_HANDLE_VALUE_)
::boost::process::v1::detail::throw_last_error("create_named_pipe(" + name + ") failed");

Expand Down
5 changes: 3 additions & 2 deletions include/boost/process/v1/locale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ inline std::locale default_locale()
std::locale global_loc = std::locale();
return std::locale(global_loc, new std::codecvt_utf8<wchar_t>);
# else // Other POSIX
// Return a default locale object.
return std::locale();
// ISO C calls std::locale("") "the locale-specific native environment", and this
// locale is the default for many POSIX-based operating systems such as Linux.
return std::locale("");
# endif
}

Expand Down
4 changes: 4 additions & 0 deletions include/boost/process/v2/default_launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#else
#if defined(BOOST_PROCESS_V2_PDFORK)
#include <boost/process/v2/posix/pdfork_launcher.hpp>
#elif defined(BOOST_PROCESS_V2_PIPEFORK)
#include <boost/process/v2/posix/pipe_fork_launcher.hpp>
#else
#include <boost/process/v2/posix/default_launcher.hpp>
#endif
Expand Down Expand Up @@ -48,6 +50,8 @@ typedef windows::default_launcher default_process_launcher;
#else
#if defined(BOOST_PROCESS_V2_PDFORK)
typedef posix::pdfork_launcher default_process_launcher;
#elif defined(BOOST_PROCESS_V2_PIPEFORK)
typedef posix::pipe_fork_launcher default_process_launcher;
#else
typedef posix::default_launcher default_process_launcher;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/boost/process/v2/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ BOOST_PROCESS_V2_END_NAMESPACE

#include <sys/syscall.h>

#if defined(SYS_pidfd_open)
#if defined(SYS_pidfd_open) && !defined(BOOST_PROCESS_V2_DISABLE_PIDFD_OPEN)
#define BOOST_PROCESS_V2_PIDFD_OPEN 1
#define BOOST_PROCESS_V2_HAS_PROCESS_HANDLE 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/boost/process/v2/detail/process_handle_fd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct basic_process_handle_fd
ec.clear();
exit_code = code;
}
return false;
return false;
}

bool running(native_exit_code_type &exit_code)
Expand Down
80 changes: 50 additions & 30 deletions include/boost/process/v2/detail/process_handle_fd_or_signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,27 @@

#if defined(BOOST_PROCESS_V2_STANDALONE)
#include <asio/any_io_executor.hpp>
#include <asio/append.hpp>
#include <asio/associated_immediate_executor.hpp>
#include <asio/compose.hpp>
#include <asio/dispatch.hpp>
#include <asio/posix/basic_stream_descriptor.hpp>
#include <asio/post.hpp>
#include <asio/windows/signal_set.hpp>
#if !defined(BOOST_PROCESS_V2_DISABLE_SIGNALSET)
#include <asio/signal_set.hpp>
#endif
#else
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/append.hpp>
#include <boost/asio/associated_immediate_executor.hpp>
#include <boost/asio/compose.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/posix/basic_stream_descriptor.hpp>
#include <boost/asio/post.hpp>
#if !defined(BOOST_PROCESS_V2_DISABLE_SIGNALSET)
#include <boost/asio/signal_set.hpp>
#endif
#endif

BOOST_PROCESS_V2_BEGIN_NAMESPACE

Expand All @@ -45,7 +53,7 @@ struct basic_process_handle_fd_or_signal
typedef Executor executor_type;

executor_type get_executor()
{ return signal_set_.get_executor(); }
{ return descriptor_.get_executor(); }

/// Rebinds the process_handle to another executor.
template<typename Executor1>
Expand Down Expand Up @@ -277,14 +285,13 @@ struct basic_process_handle_fd_or_signal
int res = ::waitpid(pid_, &code, WNOHANG);
if (res == -1)
ec = get_last_error();
else
ec.clear();

if (process_is_running(res))
else if (res == 0)
return true;
else
{
ec.clear();
exit_code = code;

}
return false;
}

Expand All @@ -311,12 +318,19 @@ struct basic_process_handle_fd_or_signal
struct basic_process_handle_fd_or_signal;
pid_type pid_ = -1;
net::posix::basic_stream_descriptor<Executor> descriptor_;
#if !defined(BOOST_PROCESS_V2_DISABLE_SIGNALSET)
net::basic_signal_set<Executor> signal_set_{descriptor_.get_executor(), SIGCHLD};

#else
int signal_set_;
#endif
struct async_wait_op_
{
net::posix::basic_descriptor<Executor> &descriptor;
#if !defined(BOOST_PROCESS_V2_DISABLE_SIGNALSET)
net::basic_signal_set<Executor> &handle;
#else
int dummy;
#endif
pid_type pid_;
bool needs_post = true;

Expand All @@ -343,35 +357,41 @@ struct basic_process_handle_fd_or_signal

if (!ec && (wait_res == 0))
{
needs_post = false;
if (descriptor.is_open())
descriptor.async_wait(
net::posix::descriptor_base::wait_read,
std::move(self));
{
needs_post = false;
descriptor.async_wait(
net::posix::descriptor_base::wait_read,
std::move(self));
return;
}
else
handle.async_wait(std::move(self));
return;
}

struct completer
{
error_code ec;
native_exit_code_type code;
typename std::decay<Self>::type self;

void operator()()
{
self.complete(ec, code);
#if !defined(BOOST_PROCESS_V2_DISABLE_SIGNALSET)
needs_post = false;
handle.async_wait(std::move(self));
return;
#else
BOOST_PROCESS_V2_ASSIGN_EC(ec, net::error::operation_not_supported);
#endif
}
};
}

const auto exec = self.get_executor();
completer cpl{ec, exit_code, std::move(self)};
if (needs_post)
net::post(exec, std::move(cpl));
{
auto exec = net::get_associated_immediate_executor(self, descriptor.get_executor());
net::dispatch(exec, net::append(std::move(self), exit_code, ec));
}
else
net::dispatch(exec, std::move(cpl));

{
auto exec = net::get_associated_executor(self);
net::dispatch(exec, net::append(std::move(self), exit_code, ec));
}
}
template<typename Self>
void operator()(Self &&self, native_exit_code_type code, error_code ec)
{
self.complete(ec, code);
}
};
public:
Expand Down
Loading
Loading