41 KiB
Changelog
14.2.4
- Bugfix: Fix a memory leak in
reproc_start()on Windows (thanks @AokiYuune). - Bugfix: Fix a memory leak in reproc++
arrayclass move constructor. - Allow passing zero-sized array's to reproc's
inputoption (thanks @lightray22).
14.2.3
- Bugfix: Fix sign of EWOULDBLOCK error returned from
reproc_read.
14.2.2
- Bugfix: Disallow using
forkoption when usingreproc_run.
14.2.1
- Bugfix:
reproc_runnow handles forked child processes correctly. - Bugfix: Sinks of different types can now be passed to
reproc::drain. - Bugfix: Processes on Windows returning negative exit codes don't cause asserts anymore.
- Bugfix: Dependency on librt on POSIX (except osx) systems is now explicit in CMake.
- Bugfix: Added missing stdout redirect option to reproc++.
14.2.0
- Added
reproc_pid/process::pidto get the pid of the process - Fixed compilation error when including reproc/drain.h in C++ code
- Added missing extern "C" block to reproc/run.h
14.1.0
reproc_run/reproc::runnow return the exit code ofreproc_stop/process::stopeven if the deadline is exceeded.- A bug where deadlines wouldn't work was fixed.
14.0.0
- Renamed
environmenttoenv. - Added configurable behavior to
envoption. Extra environment variables are now added viaenv.extra. Extra environment variables now extend the parent environment by default instead of replacing it.
13.0.1
- Bugfix: Reset the
eventsparameter of every event source if a deadline expires when callingreproc_poll. - Bugfix: Return 1 from
reproc_pollif a deadline expires. - Bugfix: Don't block in
reproc_readon Windows if thenonblockingoption was specified.
13.0.0
-
Allow passing empty event sources to
reproc_poll.If the
processmember of areproc_event_sourceobject isNULL,reproc_pollignores the event source. -
Return zero from
reproc_pollif the given timeout expires instead ofREPROC_ETIMEDOUT.In reproc, we follow the general pattern that we don't modify output arguments if an error occurs. However, when
reproc_pollerrors, we still want to set all events of the given event sources to zero. To signal that we're modifying the output arguments if the timeout expires, we return zero instead ofREPROC_ETIMEDOUT. This is also more consistent withpollandWSAPollwhich have the same behaviour. -
If one or more events occur, return the number of processes with events from
reproc_poll.
12.0.0
reproc
-
Put pipes in blocking mode by default.
This allows using
reproc_readandreproc_writedirectly without having to figure outreproc_poll. -
Add
nonblockingoption.Allows putting pipes back in nonblocking mode if needed.
-
Child process stderr streams are now redirected to the parent stderr stream by default.
Because pipes are blocking again by default, there's a (small) chance of deadlocks if we redirect both stdout and stderr to pipes. Redirecting stderr to the parent by default avoids that issue.
The other (bigger) issue is that if we redirect stderr to a pipe, there's a good chance users might forget to read from it and discard valuable error output from the child process.
By redirecting to the parent stderr by default, it's immediately noticeable when a child process is not behaving according to expectations as its error output will appear directly on the parent process stderr stream. Users can then still decide to explicitly discard the output from the stderr stream if needed.
-
Turn
timeoutoption into an argument forreproc_poll.While deadlines can differ per process, the timeout is very likely to always be the same so we make it an argument to the only function that uses it, namely
reproc_poll. -
In
reproc_drain, callsinkonce with an empty buffer when a stream is closed.This allows sinks to handle stream closure if needed.
-
Change sinks to return
intinstead ofbool. If asinkreturns a non-zero value,reproc_drainexits immediately with the same value.This change allows sinks to return their own errors without having to store extra state.
-
reproc_sink_stringnow returnsREPROC_ENOMEMfromreproc_drainif a memory allocation fails and no longer frees any output that was read previously.This allows the user to still do something with the remaining output even if a memory allocation failed. On the flipside, it is now required to always call
reproc_freeafter callingreproc_drainwith a sink string, even if it fails. -
Renamed sink.h to drain.h.
Reflect that sink.h contains
reproc_drainby renaming it to drain.h. -
Add
REPROC_REDIRECT_PATHand shorthandpathoptions.
reproc++
-
Equivalent changes as those done for reproc.
-
Remove use of reprocxx.
Meson gained support for CMake subprojects containing targets with special characters so we rename directories and CMake targets back to reproc++.
11.0.0
General
- Compilation now happens with compiler extensions disabled (
-std=c99and-std=c++11).
reproc
-
Add
inheritanddiscardoptions as shorthands to set all members of theredirectoptions toREPROC_REDIRECT_INHERITandREPROC_REDIRECT_DISCARDrespectively. -
Add
reproc_runandreproc_run_exwhich allows running a process using only a single function.Running a simple process with reproc required calling
reproc_new,reproc_start,reproc_waitand optionallyreproc_drainwith all the associated error handling.reproc_runencapsulates all this boilerplate. -
Add
inputoption that writes the given to the child process stdin pipe before starting the process.This allows passing input to the process when using
reproc_run. -
Add
deadlineoption that specifies a point in time beyond whichreproc_pollwill returnREPROC_ETIMEDOUT. -
Add
REPROC_DEADLINEthat makesreproc_waitwait until the deadline specified in thedeadlineoption has expired.By default, if the
deadlineoption is set,reproc_destroywaits until the deadline expires before sending aSIGTERMsignal to the child process. -
Add (POSIX only)
forkoption that makesreproc_starta safe alternative toforkwith support for all of reproc's other features. -
Return the amount of bytes written from
reproc_writeand stop handling partial writes.Now that reproc uses nonblocking pipes, it doesn't make sense to handle partial writes anymore. The
inputoption can be used as an alternative.reproc_startkeeps writing until all data frominputis written to the child process stdin pipe or until a call toreproc_writereturns an error. -
Add
reproc_pollto query child process events of one or more child processes.We now support polling multiple child processes for events.
reproc_pollmimicks the POSIXpollfunction but instead of pollfds, it takes a list of event sources which consist out of a process, the events we're interested in and an output field which is filled in byreproc_pollthat contains the events that occurred for that child process. -
Stop reading from both stdout and stderr in
reproc_read.Because we now have
reproc_poll,reproc_readwas simplified to again read from the given stream which is passed again as an argument. To avoid deadlocks, callreproc_pollto figure out the first stream that has data available to read. -
Support polling for process exit events.
By adding
REPROC_EVENT_EXITto the list of interested events, we can poll for child process exit events. -
Add a dependency on Winsock2 on Windows.
To implement
reproc_poll, we redirect to sockets on Windows which allows us to useWSAPollwhich is required to implementreproc_poll. Using sockets on Windows requires linking with thews2_32library. This dependency is automatically handled by CMake and pkg-config. -
Move
in,outanderroptions out ofstdiodirectly intoredirect.This reduces the amount of boilerplate when redirecting streams.
-
Rename
REPROC_REDIRECT_INHERITtoREPROC_REDIRECT_PARENT.REPROC_REDIRECT_PARENTmore clearly indicates that we're redirecting to the parent's corresponding standard stream. -
Add support for redirecting to operating system handles.
This allows redirecting to operating system-specific handles. On POSIX systems, this feature expects file descriptors. On Windows, it expects
HANDLEs orSOCKETs. -
Add support for redirecting to
FILE *s.This gives users a cross-platform way to redirect standard streams to files.
-
Add support for redirecting stderr to stdout.
For high-traffic scenarios, it doesn't make sense to allocate a separate pipe for stderr if its output is only going to be combined with the output of stdout. By using
REPROC_REDIRECT_STDOUTfor stderr, its output is written directly to stdout by the child process. -
Turn
redirect'sin,outanderroptions into instances of the newreproc_redirecŧstruct.An enum didn't cut it anymore for the new file and handle redirect options since those require extra fields to allow specifying which file or handle to redirect to.
-
Add
redirect.fileoption as a shorthand for redirecting stdout and stderr to the same file.
reproc++
-
reproc++ includes mostly the same changes done to reproc so we only document the differences.
-
Add
forkmethod instead offorkoption.Adding a
forkoption would have required changingstartto returnstd::pair<bool, std::error_code>to allow determining whether we're in the parent or the child process after a fork. However, the bool return value would only be valid when the fork option was enabled. Thus, this approach would unnecessarily complicate all other use cases ofstartthat don't requirefork. To solve the issue, we madeforka separate method instead.
10.0.3
reproc
-
Fixed issue where
reproc_waitwould assert when invoked with a timeout of zero on POSIX. -
Fixed issue where
reproc_waitwould not returnREPROC_ETIMEDOUTwhen invoked with a timeout of zero on POSIX.
10.0.2
- Update CMake project version.
10.0.1
reproc
- Pass
timeoutonce viareproc_optionsinstead of passing it viareproc_read,reproc_writeandreproc_drain.
reproc++
- Pass
timeoutonce viareproc::optionsinstead of passing it viaprocess::read,process::writeandreproc::drain.
10.0.0
reproc
-
Remove
reproc_parse.Instead of checking for
REPROC_EPIPE(previouslyREPROC_ERROR_STREAM_CLOSED), simply check if the given parser has a full message available. If it doesn't, the output streams closed unexpectedly. -
Remove
reproc_runningandreproc_exit_status.When calling
reproc_running, it would wait with a zero timeout if the process was still running and check if the wait timed out. However, a call to wait can fail for other reasons as well which were all ignored byreproc_running. Instead ofreproc_running, A call toreproc_waitwith a timeout of zero should be used to check if a process is still running.reproc_waitnow also returns the exit status if the process exits or has already exited which removes the need forreproc_exit_status. -
Read from both stdout and stderr in
reproc_readto avoid deadlocks and indicate which streamreproc_readwas read from.Previously, users would indicate the stream they wanted to read from when calling
reproc_read. However, this lead to issues with programs that write to both stdout and stderr as a user wouldn't know whether stdout or stderr would have output available to read. Reading from only the stdout stream didn't work as the parent could be blocked on reading from stdout while the child was simultaneously blocked on writing to stderr leading to a deadlock. To get around this, users had to start up a separate thread to read from both stdout and stderr at the same time which was a lot of extra work just to get the output of external programs that write to both stdout and stderr. Now, reproc takes care of avoiding the deadlock by checking which of stdout/stderr can be read from, doing the actual read and indicating to the user which stream was read from.Practically, instead of passing
REPROC_STREAM_OUTorREPROC_STREAM_ERRtoreproc_read, you now pass a pointer to aREPROC_STREAMvariable instead whichreproc_readwill set toREPROC_STREAM_OUTorREPROC_STREAM_ERRdepending on which stream it read from.If both streams have been closed by the child process,
reproc_readreturnsREPROC_EPIPE.Because of the changes to
reproc_read,reproc_drainnow also reads from both stdout and stderr and indicates the stream that was read from to the given sink function via an extra argument passed to the sink. -
Read the output of both stdout and stderr into a single contiguous null-terminated string in
reproc_sink_string. -
Remove the
bytes_writtenparameter ofreproc_write.reproc_writenow always writessizebytes to the standard input of the child process. Partial writes do not have to be handled by users anymore and are instead handled by reproc internally. -
Define
_GNU_SOURCEand_WIN32_WINNTonly in the implementation files that need them.This helps keep track of where we're using functionality that requires extra definitions and makes building reproc in all kinds of build systems simpler as the compiler invocations to build reproc get smaller as a result.
-
Change the error handling in the public API to return negative
errno(POSIX) orGetLastError(Windows) style values.REPROC_ERRORis replaced by extern constants that are assigned the correct error value based on the platform reproc is built for. Instead of returningREPROC_ERROR, most functions in reproc's API now returnintwhen they can fail. Because system errors are now returned directly, there's no need anymore forREPROC_ERRORandreproc_error_systemand they has been removed.Error handling before 10.0.0:
REPROC_ERROR error = reproc_start(...); if (error) { goto finish; } finish: if (error) { fprintf(stderr, "%s", reproc_strerror(error)); }Error handling from 10.0.0 onwards:
int r = reproc_start(...); if (r < 0) { goto finish; } finish: if (r < 0) { fprintf(stderr, "%s", reproc_strerror(r)); } -
Hide the internals of
reproc_t.Instances of
reproc_tare now allocated on the heap by callingreproc_new.reproc_destroyreleases the memory allocated byreproc_new. -
Take optional arguments via the
reproc_optionsstruct inreproc_start.When using designated initializers, calls to
reproc_startare now much more readable than before. Using a struct also makes it much easier to set all options to their default values (reproc_options options = { 0 };). Finally, we can add more options in further releases without requiring existing users to change their code. -
Support redirecting the child process standard streams to
/dev/null(POSIX) orNUL(Windows) inreproc_startvia theredirectfield inreproc_options.This is especially useful when you're not interested in the output of a child process as redirecting to
/dev/nulldoesn't require regularly flushing the output pipes of the process to prevent deadlocks as is the case when redirecting to pipes. -
Support redirecting the child process standard streams to the parent process standard streams in
reproc_starŧvia theredirectfield inreproc_options.This is useful when you want to interleave child process output with the parent process output.
-
Modify
reproc_startandreproc_destroyto work like the reproc++processclass constructor and destructor.The
stop_actionsfield inreproc_optionscan be used to define up to three stop actions that are executed whenreproc_destroyis called if the child process is still running. If no explicit stop actions are given,reproc_destroydefaults to waiting indefinitely for the child process to exit. -
Return the amount of bytes read from
reproc_readif it succeeds.This is made possible by the new error handling scheme. Because errors are all negative values, we can use the positive range of an
intas the normal return value if no errors occur. -
Return the exit status from
reproc_waitandreproc_stopif they succeed.Same reasoning as above. If the child process has already exited,
reproc_waitandreproc_stopsimply returns the exit status again. -
Do nothing when
NULLis passed toreproc_destroyand always returnNULLfromreproc_destroy.This allows
reproc_destroyto be safely called on the same instance multiple times when assigning the result ofreproc_destroyto the same instance (process = reproc_destroy(process)). -
Take stop actions via the
reproc_stop_actionsstruct inreproc_stop.This makes it easier to store stop action configurations both in and outside of reproc.
-
Add 256 to signal exit codes returned by
reproc_waitandreproc_stop.This prevents conflicts with normal exit codes.
-
Add
REPROC_SIGTERMandREPROC_SIGKILLconstants to match against signal exit codes.These also work on Windows and correspond to the exit codes returned by sending the
CTRL-BREAKsignal and callingTerminateProcessrespectively. -
Rename
REPROC_CLEANUPtoREPROC_STOP.Naming the enum after the function it is passed to (
reproc_stop) is simpler than using a different name. -
Rewrite tests in C using CTest and
assertand remove doctest.Doctest is a great library but we don't really lose anything major by replacing it with CTest and asserts. On the other hand, we lose a dependency, don't need to download stuff from CMake anymore and tests compile significantly faster.
Tests are now executed by running
cmake --build build --target test. -
Return
REPROC_EINVALfrom public API functions when passed invalid arguments. -
Make
reproc_strerrorthread-safe. -
Move
reproc_drainto sink.h. -
Make
reproc_draintake a separate sink for each output stream. Sinks are now passed via thereproc_sinktype.Using separate sinks for both output streams allows for a lot more flexibility. To use a single sink for both output streams, simply pass the same sink to both the
outanderrarguments ofreproc_drain. -
Turn
reproc_sink_stringandreproc_sink_discardinto functions that return sinks and hide the actual functions in sink.c. -
Add
reproc_freeto sink.h which must be used to free memory allocated byreproc_sink_string.This avoids issues with allocating across module (DLL) boundaries on Windows.
-
Support passing timeouts to
reproc_read,reproc_writeandreproc_drain.Pass
REPROC_INFINITEas the timeout to retain the old behaviour. -
Use
intto represent timeout values. -
Renamed
stop_actionsfield ofreproc_optionstostop.
reproc++
-
Remove
process::parse,process::exit_statusandprocess::running.Consequence of the equivalents in reproc being removed.
-
Take separate
outanderrarguments in thesink::stringandsink::ostreamconstructors that receive output from the stdout and stderr streams of the child process respectively.To combine the output from the stdout and stderr streams, simply pass the same
stringorostreamto both theoutanderrarguments. -
Modify
process::readto return a tuple of the stream read from, the amount of bytes read and an error code. The stream read from and amount of bytes read are only valid ifprocess::readsucceeds.std::tiecan be used pre-C++17 to assign the tuple's contents to separate variables. -
Modify
process::waitandprocess::stopto return a pair of exit status and error code. The exit status is only valid ifprocess::waitorprocess::stopsucceeds. -
Alias
reproc::errortostd::errc.As OS errors are now used everywhere, we can simply use
std::errcfor all error handling instead of defining our own error code. -
Add
signal::terminateandsignal::killconstants.These are aliases for
REPROC_SIGTERMandREPROC_SIGKILLrespectively. -
Inline all sink implementations in sink.hpp.
-
Add
sink::thread_safe::stringwhich is a thread-safe version ofsink::string. -
Move
process::drainout of theprocessclass and move it to sink.hpp.process.drain(...)becomesreproc::drain(process, ...). -
Make
reproc::draintake a separate sink for each output stream.Same reasoning as
reproc_drain. -
Modify all included sinks to support the new
reproc::drainbehaviour. -
Support passing timeouts to
process::read,process::writeandreproc::drain.They still default to waiting indefinitely which matches their old behaviour.
-
Renamed
stop_actionsfield ofreproc::optionstostop.
CMake
-
Drop required CMake version to CMake 3.12.
-
Add CMake 3.16 as a supported CMake version.
-
Build reproc++ with
-pthreadwhenREPROC_MULTITHREADEDis enabled.See https://github.com/DaanDeMeyer/reproc/issues/24 for more information.
-
Add
REPROC_WARNINGSoption (default:OFF) to build with compiler warnings. -
Add
REPROC_DEVELOPoption (default:OFF) which enables a lot of options to simplify developing reproc.By default, most of reproc's CMake options are disabled to make including reproc in other projects as simple as possible. However, when working on reproc, we usually wants most options enabled instead. To make enabling all options simpler,
REPROC_DEVELOPwas added from which most other options take their default value. As a result, enablingREPROC_DEVELOPenables all options related to developing reproc. Additionally,REPROC_DEVELOPtakes its initial value from an environment variable of the same name so it can be set once and always take effect whenever running CMake on reproc's source tree. -
Add
REPROC_OBJECT_LIBRARIESoption to build CMake object libraries.In CMake, linking a library against a static library doesn't actually copy the object files from the static library into the library. Instead, both static libraries have to be installed and depended on by the final executable. By using CMake object libraries, the object files are copied into the depending static library and no extra artifacts are produced.
-
Enable
REPROC_INSTALLby default unlessREPROC_OBJECT_LIBRARIESis enabled.As
REPROC_OBJECT_LIBRARIEScan now be used to depend on reproc without generating extra artifacts, we assume that users not usingREPROC_OBJECT_LIBRARIESwill want to install the produced artifacts. -
Rename reproc++ to reprocxx inside the CMake build files.
This was done to allow using reproc as a Meson subproject. Meson doesn't accept the '+' character in target names so we use 'x' instead.
-
Modify the export headers so that the only extra define necessary is
REPROC_SHAREDwhen using reproc as a shared library on Windows.Naturally, this define is added as a CMake usage requirement and doesn't have to be worried about when using reproc via
add_subdirectoryorfind_package.
9.0.0
General
-
Drop support for Windows XP.
-
Add support for custom environments.
reproc_startandprocess::startnow take an extraenvironmentparameter that allows specifying custom environments.IMPORTANT: The
environmentparameter was inserted before theworking_directoryparameter so make sure to update existing usages ofreproc_startandprocess::startso that theenvironmentandworking_directoryarguments are specified in the correct order.To keep the previous behaviour, pass
nullptras the environment toreproc_start/process::startor use theprocess::startoverload without theenvironmentparameter. -
Remove
argcparameter fromreproc_startandprocess::start.We can trivially calculate
argcinternally in reproc sinceargvis required to end with aNULLvalue. -
Improve implementation of
reproc_waitwith a timeout on POSIX systems.Instead of spawning a new process to implement the timeout, we now use
sigtimedwaiton Linux andkqueueon macOS to wait onSIGCHLDsignals and check if the process we're waiting on has exited after each receivedSIGCHLDsignal. -
Remove
vforkusage.Clang analyzer was indicating a host of errors in our usage of
vfork. We also discovered tests were behaving differently on macOS depending on whethervforkwas enabled or disabled. As we do not have the expertise to verify ifvforkis working correctly, we opt to remove it. -
Ensure passing a custom working directory and a relative executable path behaves consistently on all supported platforms.
Previously, calling
reproc_startwith a relative executable path combined with a custom working directory would behave differently depending on which platform the code was executed on. On POSIX systems, the relative executable path would be resolved relative to the custom working directory. On Windows, the relative executable path would be resolved relative to the parent process working directory. Now, relative executable paths are always resolved relative to the parent process working directory. -
Reimplement
reproc_drain/process::drainin terms ofreproc_parse/process::parse.Like
reproc_parseandprocess::parse,reproc_drainandprocess::drainare now guaranteed to always be called once with an empty buffer before reading any actual data.We now also guarantee that the initial empty buffer is not
NULLornullptrso the received data and size can always be safely passed tomemcpy. -
Add MinGW support.
MinGW CI builds were also added to prevent regressions in MinGW support.
reproc
-
Update
reproc_strerrorto return the actual system error string of the error code returned byreproc_system_errorinstead of "system error" when passedREPROC_ERROR_SYSTEMas argument.This should make debugging reproc errors a lot easier.
-
Add
reproc_sink_stringinsink.h, a sink that stores all process output in a single null-terminated C string. -
Add
reproc_sink_discardinsink.h, a sink that discards all process output.
reproc++
-
Move sinks into
sinknamespace and remove_sinksuffix from all sinks. -
Add
discardsink that discards all output read from a stream.This is useful when a child process produces a lot of output that we're not interested in and cannot handle the output stream being closed or full. When this is the case, simply start a thread that drains the stream with a
discardsink. -
Update
process::startto work with any kind of string type.Every string type that implements a
sizemethod and the index operator can now be passed in a container toprocess::start.working_directorynow takes aconst char *instead of astd::string *. -
Fix compilation error when using
process::parse.
8.0.1
-
Correctly escape arguments on Windows.
See #18 for more information.
8.0.0
-
Change
reproc_parseandreproc_drainargument order.contextis now the last argument instead of the first. -
Use
uint8_t *as buffer type instead ofchar *orvoid *uint8_t *more clearly indicates reproc is working with buffers of bytes thanchar *andvoid *. We chooseuint8_t *overchar *to avoid errors caused by passing data read by reproc directly to functions that expect null-terminated strings (data read by reproc is not null-terminated).
7.0.0
General
-
Rework error handling.
Trying to abstract platform-specific errors in
REPROC_ERRORandreproc::errcturned out to be harder than expected. On POSIX it remains very hard to figure out which errors actually have a chance of happening and matchingreproc::errcvalues tostd::errcvalues is also ambiguous and prone to errors. On Windows, there's hardly any documentation on which system errors functions can return so 90% of the time we were just returningREPROC_UNKNOWN_ERROR. Furthermore, many operating system errors will be fatal for most users and we suspect they'll all be handled similarly (stopping the application or retrying).As a result, in this release we stop trying to abstract system errors in reproc. All system errors in
REPROC_ERRORwere replaced by a single value (REPROC_ERROR_SYSTEM).reproc::errcwas renamed toreproc::errorand turned into an error code instead of an error condition and only contains the reproc-specific errors.reproc users can still retrieve the specific system error using
reproc_system_error.reproc++ users can still match against specific system errors using the
std::errcerror condition enum (https://en.cppreference.com/w/cpp/error/errc) or print a string presentation of the error using themessagemethod ofstd::error_code.All values from
REPROC_ERRORare now prefixed withREPROC_ERRORinstead ofREPROCwhich helps reduce clutter in code completion. -
Azure Pipelines CI now includes Visual Studio 2019.
-
Various smaller improvements and fixes.
CMake
-
Introduce
REPROC_MULTITHREADEDto configure whether reproc should link against pthreads.By default,
REPROC_MULTITHREADEDis enabled to prevent accidental undefined behaviour caused by forgetting to enableREPROC_MULTITHREADED. Advanced users might want to disableREPROC_MULTITHREADEDwhen they know for certain their code won't use more than a single thread. -
doctest is now downloaded at configure time instead of being vendored inside the reproc repository.
doctest is only downloaded if
REPROC_TESTis enabled.
6.0.0
General
-
Added Azure Pipelines CI.
Azure Pipelines provides 10 parallel jobs which is more than Travis and Appveyor combined. If it turns out to be reliable Appveyor and Travis will likely be dropped in the future. For now, all three are enabled.
-
Code cleanup and refactoring.
CMake
- Renamed
REPROC_TESTStoREPROC_TEST. - Renamed test executable from
teststotest.
reproc
-
Renamed
reproc_typetoreproc_t.We chose
reproc_typeinitially because_tbelongs to POSIX but we switch to using_tbecausereprocis a sufficiently unique name that we don't have to worry about naming conflicts. -
reproc now keeps track of whether a process has exited and its exit status.
Keeping track of whether the child process has exited allows us to remove the restriction that
reproc_wait,reproc_terminate,reproc_killandreproc_stopcannot be called again on the same process after completing successfully once. Now, if the process has already exited, these methods don't do anything and returnREPROC_SUCCESS. -
Added
reproc_runningto allow checking whether a child process is still running. -
Added
reproc_exit_statusto allow querying the exit status of a process after it has exited. -
reproc_waitandreproc_stoplost theirexit_statusoutput parameter.Use
reproc_exit_statusinstead to retrieve the exit status.
reproc++
-
Added
process::runningandprocess::exit_status.These delegate to
reproc_runningandreproc_exit_statusrespectively. -
process::waitandprocess::stoplost theirexit_statusoutput parameter.Use
process::exit_statusinstead.
5.0.1
reproc++
- Fixed compilation error caused by defining
reproc::process's move assignment operator as default in the header which is not allowed when astd::unique_ptrmember of an incomplete type is present.
5.0.0
General
- Added and rewrote implementation documentation.
- General refactoring and simplification of the source code.
CMake
-
Raised minimum CMake version to 3.13.
Tests are now added to a single target
reproc-testsin each subdirectory included withadd_subdirectory. Dependencies required to run the added tests are added toreproc-testswithtarget_link_libraries. Before CMake 3.13,target_link_librariescould not modify targets created outside of the current directory which is why CMake 3.13 is needed. -
REPROC_CIwas renamed toREPROC_WARNINGS_AS_ERRORS.This is a side effect of upgrading cddm. The variable was renamed in cddm to more clearly indicate its purpose.
-
Removed namespace from reproc's targets.
To link against reproc or reproc++, you now have to link against the target without a namespace prefix:
find_package(reproc) # or add_subdirectory(external/reproc) target_link_libraries(myapp PRIVATE reproc) find_package(reproc++) # or add_subdirectory(external/reproc++) target_link_libraries(myapp PRIVATE reproc++)This change was made because of a change in cddm (a collection of CMake functions to make setting up new projects easier) that removed namespacing and aliases of library targets in favor of namespacing within the target name itself. This change was made because the original target can still conflict with other targets even after adding an alias. This can cause problems when using generic names for targets inside the library itself. An example clarifies the problem:
Imagine reproc added a target for working with processes asynchronously. In the previous naming scheme, we'd do the following in reproc's CMake build files:
add_library(async "") add_library(reproc::async ALIAS async)However, there's a non-negligible chance that someone using reproc might also have a target named async which would result in a conflict when using reproc with
add_subdirectorysince there'd be two targets with the same name. With the new naming scheme, we'd do the following instead:add_library(reproc-async "")This has almost zero chance of conflicting with user's target names. The advantage is that with this scheme we can use common target names without conflicting with user's target names which was not the case with the previous naming scheme.
reproc
-
Removed undefined behaviour in Windows implementation caused by casting an int to an unsigned int.
-
Added a note to
reproc_startdocs about the behaviour of using a executable path relative to the working directory combined with a custom working directory for the child process on different platforms. -
We now retrieve the file descriptor limit in the parent process (using
sysconf) instead of in the child process becausesysconfis not guaranteed to be async-signal-safe which all functions called in a child process after forking should be. -
Fixed compilation issue when
ATTRIBUTE_LIST_FOUNDwas undefined (#15).
reproc++
- Generified
process::startso it works with any container ofstd::stringsatisfying the SequenceContainer interface.
4.0.0
General
- Internal improvements and documentation fixes.
reproc
-
Added
reproc_parsewhich mimics reproc++'sprocess::parse. -
Added
reproc_drainwhich mimics reproc++'sprocess::drainalong with an example that explains how to use it.Because C doesn't support lambda's, both of these functions take a function pointer and an extra context argument which is passed to the function pointer each time it is called. The context argument can be used to store any data needed by the given function pointer.
reproc++
-
Renamed the
process::readoverload which takes a parser toprocess::parse.This breaking change was done to keep consistency with reproc where we added
reproc_parse. We couldn't add anotherreproc_readsince C doesn't support overloading so we made the decision to renameprocess::readtoprocess::parseinstead. -
Changed
process::drainsinks to return a boolean instead ofvoid.Before this change, the only way to stop draining a process was to throw an exception from the sink. By changing sinks to return
bool, a sink can telldrainto stop if an error occurs by returningfalse. The error itself can be stored in the sink if needed.
3.1.3
CMake
- Update project version in CMakeLists.txt from 3.0.0 to the actual latest version (3.1.3).
3.1.2
pkg-config
- Fix pkg-config install prefix.
3.1.0
CMake
-
Added
REPROC_INSTALL_PKGCONFIGto control whether pkg-config files are installed or not (default:ON).The vcpkg package manager has no need for the pkg-config files so we added an option to disable installing them.
-
Added
REPROC_INSTALL_CMAKECONFIGDIRandREPROC_INSTALL_PKGCONFIGDIRto control where cmake config files and pkg-config files are installed respectively (default:${CMAKE_INSTALL_LIBDIR}/cmakeand${CMAKE_INSTALL_LIBDIR}/pkgconfig).reproc already uses the values from
GNUInstallDirswhen generating its install rules which are cache variables that be overridden by users. However,GNUInstallDirsdoes not include variables for the installation directories of CMake config files and pkg-config files. vcpkg requires cmake config files to be installed to a different directory than the directory reproc used until now. These options were added to allow vcpkg to control where the config files are installed to.
3.0.0
General
-
Removed support for Doxygen (and as a result
REPROC_DOCS).All the Doxygen directives made the header docstrings rather hard to read directly. Doxygen's output was also too complicated for a simple library such as reproc. Finally, Doxygen doesn't really provide any intuitive support for documenting a set of libraries. I have an idea for a Doxygen alternative using libclang and cmark but I'm not sure when I'll be able to implement it.
CMake
-
Renamed
REPROCXXoption toREPROC++.REPROCXXwas initially chosen because CMake didn't recommend using anything other than letters and underscores for variable names. However,REPROC++turns out to work without any problems so we use it since it's the expected name for an option to build reproc++. -
Stopped modifying the default
CMAKE_INSTALL_PREFIXon Windows.In 2.0.0, when installing to the default
CMAKE_INSTALL_PREFIX, you would end up withC:\Program Files (x86)\reprocandC:\Program Files (x86)\reproc++when installing reproc. In 3.0.0, the defaultCMAKE_INSTALL_PREFIXisn't modified anymore and all libraries are installed toCMAKE_INSTALL_PREFIXin exactly the same way as they are on UNIX systems (include and lib subdirectories directly beneath the installation directory). Sticking to the defaults makes it easy to include reproc in various package managers such as vcpkg.
reproc
-
reproc_terminateandreproc_killdon't callreproc_waitinternally anymore.reproc_stophas been changed to callreproc_waitafter callingreproc_terminateorreproc_killso it still behaves the same.Previously, calling
reproc_terminateon a list of processes would only callreproc_terminateon the next process after the previous process had exited or the timeout had expired. This made terminating multiple processes take longer than required. By removing thereproc_waitcall fromreproc_terminate, users can first callreproc_terminateon all processes before waiting for each of them withreproc_waitwhich makes terminating multiple processes much faster. -
Default to using
vforkinstead offorkon POSIX systems.This change was made to increase
reproc_start's performance when the parent process is using a large amount of memory. In these scenario's,vforkcan be a lot faster thanfork. Care is taken to make sure signal handlers in the child don't corrupt the state of the parent process. This change induces an extra constraint in thatset*idfunctions cannot be called while a call toreproc_startis in process, but this situation is rare enough that the tradeoff for better performance seems worth it.A dependency on pthreads had to be added in order to safely use
vfork(we needed access topthread_sigmask). The CMake and pkg-config files have been updated to automatically find pthreads so users don't have to find it themselves. -
Renamed
reproc_error_to_stringtoreproc_strerror.The C standard library has
strerrorfor retrieving a string representation of an error. By using the same function name (prefixed with reproc) for a function that does the same for reproc's errors, new users will immediately know what the function does.
reproc++
-
reproc++ now takes timeouts as
std::chrono::durationvalues (more specificreproc::milliseconds) instead of unsigned ints.Taking the
reproc::millisecondstype explains a lot more about the expected argument than taking an unsigned int. C++14 also added chrono literals which make constructingreproc::millisecondsvalues a lot more concise (reproc::milliseconds(2000)=>2000ms).