Haowen Liu
50db2113ff
Get Windows return code in wait()
...
Currently, wait() returns 0 on windows regardless
of the actual return code of processes.
2025-04-20 17:44:55 -04:00
Haoran Peng
3afe581c1f
Fix issues #103 and #104 ( #106 )
2025-03-22 23:25:37 +05:30
Hennadii Stepanov
4025693dec
Fix exception when CreateProcessW
fails and add test for it ( #98 )
...
* Fix exception when `CreateProcessW` fails
This change makes the behavior on Windows consistent with the behavior
on Linux.
* test: Add `test_exception`
2024-01-25 12:01:40 +05:30
Hennadii Stepanov
40bcc2daa9
Fix redirection from StdError on Windows ( #96 )
...
* Fix redirection from StdError on Windows
* test: Add cross-platform test for error redirection
2023-12-03 18:10:57 +05:30
Hennadii Stepanov
06858e5fd7
test: Adjust test_ret_code
for Windows and re-enable it ( #97 )
2023-12-03 18:10:05 +05:30
Hennadii Stepanov
d19cce111c
msvc: Fix "warning C4101: 'status': unreferenced local variable" ( #94 )
...
This change is required to build downstream projects using MSVC with
the `/WX` compiler option.
No behavior changes.
2023-12-01 09:43:14 +05:30
Anton Nikolaev
d809374661
fix overload thread ( #92 )
...
Co-authored-by: Anton Nikolayev <anton.nikolayev@ringcentral.com>
2023-08-28 09:57:30 +05:30
xoviat
64f4dfc2e5
remove changes to quote_argument and bring back ci for all platforms ( #91 )
...
* revert channges to quote argument
* ci: add cmake draft
* ci: enable suprocess tests
* cleanup some warnings
* ci: disable nonworking windows tests
* ci: set timeout
* ci: disable nonworking tests on windows
* ci: remove travis
---------
Co-authored-by: xoviat <xoviat@users.noreply.github.com>
2023-08-28 09:54:20 +05:30
Santiago
5a8adeb758
Added 'call' overload ( #89 )
...
* Added 'call' overload
* Use CREATE_NO_WINDOW flag for process creation in Win32
* Change way of quoting arguments so explorer /select can be called
(should find a better way to do this)
---------
Co-authored-by: Santiago <san@san.san>
2023-08-19 12:25:29 +05:30
Mikhail Sokolovskiy
1392c47cbb
Create Popen::communicate overload for std::string ( #82 )
...
* Create Popen::communicate overload for std::string
* Create Popen::send overload for std::string
2022-06-25 20:50:38 +05:30
Jake Zimmerman
2ef9f168d3
Add retcode to CalledProcessError ( #81 )
...
It's useful to be able to know the exit code of the process when it
fails with a non-zero exit code.
To get this to work, I had to fix a bug in the implementation of
check_output. Previously, check_output would call both `p.communicate()`
and `p.poll()`. The former has the effect of waiting for EOF on the
input and then waiting for the child to exit, reaping it with
`waitpid(2)`. Unfortunately, `p.poll()` was hoping to be able to also
use `waitpid(2)` to retrieve the exit code of the process. But since the
child had already been reaped, the given pid no longer existed, and thus
`waitpid(2)` would return `ECHILD`.
Luckily the call to `p.poll()` is unnecessary, as the process already
provides `p.retcode()` for retrieving the exit code.
2022-05-29 09:48:20 +05:30
philippewarren
bf4289c1a0
Fix execute_process blocking on Windows ( #76 )
2022-05-15 21:40:30 +05:30
Elazar Leibovich
2bec886e79
Clang tidy ( #73 )
...
* clang-tidy: reorder includes
* clang-tidy: explicit one argument constructors
Co-authored-by: Elazar Leibovich <elazar.leibovich@nextsilicon.com>
2022-03-18 09:21:04 +05:30
Dean Sands
fa58db9d6e
Issues #43 , #58 and #60 ( #59 )
...
* Issue 43: some functions are not inline
* Issue #60 : MinGW support
2020-09-29 19:19:47 +05:30
Dean Sands
5f43a237dc
Patched code to handle environment modifications ( #62 )
2020-09-29 19:19:02 +05:30
Arun M
718d0c816a
merge
2020-06-13 13:06:28 +05:30
Arun M
dafa7dd36b
string comparison issue on win32 #55
2020-06-13 13:06:00 +05:30
Németh Ádám
2f6bb248c6
fix for poll() function where the _child_created value is only ever set when not compiling on windows so on windows it should be omitted ( #56 )
2020-05-03 22:24:29 +05:30
Dilshod Mukhtarov
f1a698b50e
Forked subprocess not exited if execve failed ( #54 )
...
* Fixed: forked subprocess not exited if execve failed
In lengthy processes (daemons, etc) this bug keeps open this subprocess. The subprocess continues to work (parallel to parent process) from after failed command start
* Fixed: deadlock on using multithreaded application
For example if application uses spdlog logger library and set spdlog::flush_every(std::chrono::seconds(1)); then it starts it's own thread which flushes logs every 1 second. In this case if execve failed to execute given command, then parent and subprocess deadlocked.
2020-04-14 20:29:25 +05:30
xoviat
9c624ce4e3
Enable basic windows support ( #33 )
...
* windows: fix implementation error
- repair configure_pipe
- allow vector initialization
- add draft destructor
- close pipes correctly
* windows: add some test compatibility
* windows: update readme
* windows: add vector args to check_output
2020-01-18 20:01:03 +05:30
CrashOverride
126ee2978f
Update subprocess.hpp ( #51 )
...
fixed type
2019-11-23 22:49:14 +05:30
Adam Kewley
a5cc965f72
Remove trailing semicolons on namespace decls: required to build with -pedantic compiler flag ( #45 )
2019-08-28 22:22:11 +05:30
bibermann
785ff230a8
Allow usage in multiple object files ( #39 )
2019-07-10 17:13:15 +05:30
xoviat
f6799fcc34
WIP: add windows compatibility ( #32 )
...
* windows: add util functions
* windows: add cmake files
* windows: add travis.yml
* windows: address compatibility
- set cxx standard
- conditionally exclude codecvt
* windows: improve test coverage
* windows: improve test coverage
* windows: consolidate tests
* windows: disable failing test
* windows: modify read_atmost_n to use file object
* windows: modify read_all to use file object
* windows: update read_all test to use new api
* windows: implement main subprocess logic
* windows: add macro names
* windows: setup comm channels
* windows: compatibility fixes
2019-05-09 22:02:58 +05:30
Arun Muralidharan
871577770a
Revert "WIP: Add windows compatibility ( #30 )" ( #31 )
...
This reverts commit 5d92f4849276aa313dc1ba56c1556f4cca27fc7f.
2019-05-02 12:24:40 +05:30
xoviat
5d92f48492
WIP: Add windows compatibility ( #30 )
...
* add package files
* add windows compat to subprocess.hpp
* add test modifications
* repair test_read_all
2019-05-02 12:02:17 +05:30
jvilk-stripe
de5f791d04
Add virtual destructor to HolderBase ( #28 )
2019-03-11 12:44:12 +05:30
Gerardwx
3e29149ad1
Change rethrow statements ( #25 )
2019-01-26 13:08:44 +05:30
mohamedAlaaK
d74481c564
fixed a bug in util::read_all() function and added a test for it ( #23 )
2019-01-03 21:59:49 +05:30
Arun M
7ebcd80c05
Merge conflict
2018-12-31 17:43:15 +05:30
Arun M
ced3d53e3a
I can send() but I have no way of closing the input channel #21
2018-12-31 17:41:24 +05:30
ilue
0894e7f6db
Fix for preexec_func ( #19 )
2018-12-22 00:37:51 +05:30
Ben Dang
899e9b997d
Replace throw with noexcept for C17 compatibility ( #17 )
...
C++11 started to deprecate the use of throw function identifiers. In
C++17, this header no longer compiles due to the deprecation.
Signed-off-by: Ben Dang <me@bdang.it>
2018-10-08 12:45:10 +05:30
Arun M
a90174cf5c
is throwing errors #16
2018-09-30 10:10:40 +05:30
Arun M
05c76a5311
Reading from a pipe is messed up #14
2018-04-16 10:50:46 +05:30
Arun M
b5e3da1cf7
Cannot access process retcode after #13
2018-04-14 22:51:06 +05:30
Dmitry Petrashko
4cc467e2aa
Fix lto build on clang by marking HolderBase::operator() as abstract ( #12 )
2018-03-07 09:47:12 +05:30
okaymaged
7534a9cddb
Don't waitpid on SIGCHLD, which lost the retcode ( #11 )
...
* Don't waitpid on SIGCHLD, which lost the retcode
* Adding test
2018-03-02 20:28:24 +05:30
Arun M
ca74a559c5
Fix all the compilation warnings #9
2018-03-01 16:10:05 +05:30
Andrei Preda
83da3cc629
Make all static functions inline
2017-08-22 05:06:47 -07:00
Andrei Preda
55d9433422
Fix linker errors when using library in multiple object files
2017-08-22 04:14:51 -07:00
Andrei Preda
78651742fb
Replace tabs with spaces
...
Coding style uses indent with spaces, but there were a few lost tabs
that had to be replaced.
2017-08-22 02:41:29 -07:00
Andrei Preda
c8577e3d83
Remove unused sys_ret variable
2017-08-19 16:39:09 +03:00
Andrei Preda
a665bff1bd
Make split inline
2017-08-19 16:38:49 +03:00
Andrei Preda
fb63ff77d3
Use 'friend struct' instead of 'firend class ArgumentDeducer' in Popen
...
Signed-off-by: Andrei Preda <andreipreda07@gmail.com>
2017-08-19 16:28:42 +03:00
yytdfc
814be9e635
fix a bug of defunct process by adding a SIGCHLD handler.
2017-08-04 11:14:34 +08:00
arunmu
a23c1033df
Fixed 2 issues:
...
1. When more than 2 streams are piped, we use threads to read/write data
parallely. In this scenariod read_atmost_n API was being used instead of
read_all.
2. Another issue with check_output argument validation fixed.
2016-03-21 20:25:37 +05:30
arunmu
a67cb2a439
Issue pointed by elfring: Non standard header guard
2016-03-21 18:07:05 +05:30
arunmu
5e1a9c9088
Fixed poll return status
2016-03-19 18:18:47 +05:30
arunmu
9b2e9229a5
Added documentation
2016-03-19 17:40:39 +05:30