A cross-platform (C99/C++11) process library
MIT License
Bot releases are visible (Hide)
Published by DaanDeMeyer almost 6 years ago
Internal improvements.
Published by DaanDeMeyer almost 6 years ago
See the changelog for a list of changes.
Published by DaanDeMeyer almost 6 years ago
Changes since the last beta release
Published by DaanDeMeyer almost 6 years ago
Breaking Changes
Split process::read(reproc::stream stream, Parser &&parser)
into process::read(reproc::stream stream, Parser &&parser)
and process::drain(reproc::stream stream, Sink &&sink)
. read
now reports the stream being closed as an error. The provided parser is also called once with an empty string before reading to give the parser the opportunity to completely process all previous output before reading new output from the stream. drain
differs from read
in that the sink doesn't return a bool to tell drain
to stop reading. Instead, drain
keeps reading until the stream is closed or an error occurs. drain
does not report the stream being closed as an error.
Use read
with a parser to read separate delimited messages from a stream. Use drain
to read the entire output of a stream.
Additions
Published by DaanDeMeyer almost 6 years ago
Changes
reproc::cleanup::none to reproc::cleanup::noop
REPROC_W4
(replaced by check if we're included with add_subdirectory
)REPROC_COLORED_OUTPUT
(now always enabled). Side effect: GCC min version is now 4.9REPROC_CLANG_TIDY
to REPROC_TIDY
REPROC_CLANG_FORMAT
to REPROC_FORMAT
New Features
Export headers are now generated by CMake so REPROC_SHARED
doesn't have to be defined when using reproc as a shared library.
pkg-config support
Added reproc_stop
. C doesn't support overloading so the reproc version doesn't have the overloads with less arguments that the reproc++ version has.
Example usage: reproc_stop(process, REPROC_WAIT, 10000, REPROC_TERMINATE, 5000, REPROC_NOOP, 0, &exit_status)
;
Published by DaanDeMeyer almost 6 years ago
Breaking Changes
Removed reproc_stop
and replaced it with reproc_wait
, reproc_terminate
and reproc_kill
.
Because C doesn't support function overloading I was unable to find a satisfactory design to stop a child process in a configurable way using a single function (reproc_stop
). By splitting back into separate functions simple use cases don't have to specify unnecessary arguments and complicated use cases still have full control over how they want to stop a child process.
reproc++ now also exposes separate process::wait
, process::terminate
and process::kill
methods in the process class that directly map to the corresponding reproc functions. However, because C++ does support overloaded functions and methods, reproc++ still provides process::stop
which simplifies calling combinations of process::wait
, process::terminate
and process::kill
. It now takes its arguments differently. Check the examples or the process::stop
documentation for more info. The process
constructor has been updated to take its arguments the same way.
Changed process
destructor to wait indefinitely for the child process to exit instead of only checking if the child process is still running.
reproc++ should promote correct cleanup of child processes. The previous defaults might cause users to accidentally not correctly clean up child processes. By changing the defaults to wait indefinitely, users will immediately know the child process isn't exiting for some reason which they can then solve by adding more options to the constructor.
Published by DaanDeMeyer almost 6 years ago
Bug Fixes
Features
REPROC_ARGS_TOO_LONG
and REPROC_NOT_EXECUTABLE
to REPROC_ERROR
which are reported on POSIX systems when too many arguments are passed or the given binary cannot be executed.Other
Published by DaanDeMeyer almost 6 years ago
Breaking Changes
Changed reproc_stop
, reproc::process
constructor and reproc::process::stop
to take 3 timeout values instead of a single timeout value. The timeout values are assigned to passed cleanup flags in a fixed order:
REPROC_WAIT
(reproc::cleanup::wait
)REPROC_TERMINATE
(reproc::cleanup::terminate
)REPROC_KILL
(reproc::cleanup::kill
)Example: when calling reproc_stop(&process, REPROC_WAIT | REPROC_KILL, 10000, 5000, 2000, NULL)
the function will first wait for 10 seconds before sending SIGKILL
and waiting 5 more seconds. Only two flags were passed so the third timeout value (2000) is ignored.
Removed reproc::process
constructor default values since they encouraged leaky behaviour (didn't make sure the child process was completely cleaned up).
Renamed REPROC_ENABLE_W4
CMake option to REPROC_W4
.
Published by DaanDeMeyer almost 6 years ago
Breaking Changes
REPROC_BUILD_TESTS
=> REPROC_TESTS
REPROC_BUILD_EXAMPLES
=> REPROC_EXAMPLES
REPROC_BUILD_DOCS
=> REPROC_DOCS
Published by DaanDeMeyer almost 6 years ago
Breaking Changes
<prefix>/reproc
directory, now correctly installs to <prefix>/reproc++
directory).REPROC_INSTALL=ON
(needed by CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
).Breaking Changes
The BUILD_CXX_WRAPPER
CMake option has been renamed to REPROCXX
The include namespace for the C++ API has changed from reproc to reproc++. For example: #include "reproc/reproc.hpp"
is now #include "reproc++/reproc.hpp"
.
To use the C++ API you now have to link against reproc++ instead of reproc:
target_link_libraries(myapp reproc::reproc++)
Both libraries (reproc and reproc++) are installed to the system completely separately. To find reproc in CMake: find_package(reproc)
. To find reproc++ in CMake: find_package(reproc++)
. find_package(reproc++)
automatically makes sure reproc is available.
Moving the C++ functionality to a completely separate library that depends on reproc was inspired by this talk: https://www.youtube.com/watch?v=sBP17HQAQjk&feature=youtu.be.
The rest of the changes is internal refactoring and documentation updates/additions.