@@ -159,12 +159,6 @@ class OSError: public std::runtime_error
159
159
// --------------------------------------------------------------------
160
160
namespace util
161
161
{
162
- template <typename R>
163
- inline bool is_ready (std::shared_future<R> const &f)
164
- {
165
- return f.wait_for (std::chrono::seconds (0 )) == std::future_status::ready;
166
- }
167
-
168
162
inline void quote_argument (const std::wstring &argument, std::wstring &command_line,
169
163
bool force)
170
164
{
@@ -676,8 +670,8 @@ struct error
676
670
* This is basically used to determine the length of the actual
677
671
* data stored inside the dynamically resized vector.
678
672
*
679
- * This is what is returned as the output to communicate and check_output
680
- * functions , so, users must know about this class.
673
+ * This is what is returned as the output to the communicate
674
+ * function , so, users must know about this class.
681
675
*
682
676
* OutBuffer and ErrBuffer are just different typedefs to this class.
683
677
*/
@@ -688,22 +682,6 @@ class Buffer
688
682
explicit Buffer (size_t cap) { buf.resize (cap); }
689
683
void add_cap (size_t cap) { buf.resize (cap); }
690
684
691
- #if 0
692
- Buffer(const Buffer& other):
693
- buf(other.buf),
694
- length(other.length)
695
- {
696
- std::cout << "COPY" << std::endl;
697
- }
698
-
699
- Buffer(Buffer&& other):
700
- buf(std::move(other.buf)),
701
- length(other.length)
702
- {
703
- std::cout << "MOVE" << std::endl;
704
- }
705
- #endif
706
-
707
685
public:
708
686
std::vector<char > buf;
709
687
size_t length = 0 ;
@@ -724,39 +702,9 @@ class Popen;
724
702
*/
725
703
726
704
namespace detail {
727
-
728
- // Metaprogram for searching a type within
729
- // a variadic parameter pack
730
- // This is particularly required to do a compile time
731
- // checking of the arguments provided to 'check_output' function
732
- // wherein the user is not expected to provide an 'output' option.
733
-
734
- template <typename ... T> struct param_pack {};
735
-
736
- template <typename F, typename T> struct has_type ;
737
-
738
- template <typename F>
739
- struct has_type <F, param_pack<>> {
740
- static constexpr bool value = false ;
741
- };
742
-
743
- template <typename F, typename ... T>
744
- struct has_type <F, param_pack<F, T...>> {
745
- static constexpr bool value = true ;
746
- };
747
-
748
- template <typename F, typename H, typename ... T>
749
- struct has_type <F, param_pack<H,T...>> {
750
- static constexpr bool value =
751
- std::is_same<F, typename std::decay<H>::type>::value ? true : has_type<F, param_pack<T...>>::value;
752
- };
753
-
754
- // ----
755
-
756
705
/* !
757
706
* A helper class to Popen class for setting
758
- * options as provided in the Popen constructor
759
- * or in check_output arguments.
707
+ * options as provided in the Popen constructor.
760
708
* This design allows us to _not_ have any fixed position
761
709
* to any arguments and specify them in a way similar to what
762
710
* can be done in python.
@@ -948,24 +896,23 @@ class Streams
948
896
* interface to the client.
949
897
*
950
898
* API's provided by the class:
951
- * 1. Popen({"cmd"}, output{..}, error{..}, ....)
899
+ * Popen({"cmd"}, output{..}, error{..}, ....)
952
900
* Command provided as a sequence.
953
- * 2. Popen("cmd arg1"m output{..}, error{..}, ....)
901
+ * Popen("cmd arg1", output{..}, error{..}, ....)
954
902
* Command provided in a single string.
955
- * 3. wait() - Wait for the child to exit.
956
- * 4. retcode() - The return code of the exited child.
957
- * 5. pid() - PID of the spawned child.
958
- * 6. poll() - Check the status of the running child.
959
- * 7. kill(sig_num) - Kill the child. SIGTERM used by default.
960
- * 8. send(...) - Send input to the input channel of the child.
961
- * 9. communicate(...) - Get the output/error from the child and close the channels
962
- * from the parent side.
963
- *10. input() - Get the input channel/File pointer. Can be used for
964
- * customizing the way of sending input to child.
965
- *11. output() - Get the output channel/File pointer. Usually used
966
- in case of redirection. See piping examples.
967
- *12. error() - Get the error channel/File pointer. Usually used
968
- in case of redirection.
903
+ * wait() - Wait for the child to exit.
904
+ * retcode() - The return code of the exited child.
905
+ * pid() - PID of the spawned child.
906
+ * poll() - Check the status of the running child.
907
+ * send(...) - Send input to the input channel of the child.
908
+ * communicate(...) - Get the output/error from the child and close the channels
909
+ * from the parent side.
910
+ * input() - Get the input channel/File pointer. Can be used for
911
+ * customizing the way of sending input to child.
912
+ * output() - Get the output channel/File pointer. Usually used
913
+ in case of redirection. See piping examples.
914
+ * error() - Get the error channel/File pointer. Usually used
915
+ in case of redirection.
969
916
*/
970
917
class Popen
971
918
{
@@ -1009,15 +956,6 @@ class Popen
1009
956
execute_process ();
1010
957
}
1011
958
1012
- /*
1013
- ~Popen()
1014
- {
1015
- #ifdef __USING_WINDOWS__
1016
- CloseHandle(this->process_handle_);
1017
- #endif
1018
- }
1019
- */
1020
-
1021
959
int pid () const noexcept { return child_pid_; }
1022
960
1023
961
int retcode () const noexcept { return retcode_; }
@@ -1026,10 +964,6 @@ class Popen
1026
964
1027
965
int poll () noexcept (false );
1028
966
1029
- // Does not fail, Caller is expected to recheck the
1030
- // status with a call to poll()
1031
- void kill (int sig_num = 9 );
1032
-
1033
967
void set_out_buf_cap (size_t cap) { stream_.set_out_buf_cap (cap); }
1034
968
1035
969
void set_err_buf_cap (size_t cap) { stream_.set_err_buf_cap (cap); }
@@ -1197,18 +1131,6 @@ inline int Popen::poll() noexcept(false)
1197
1131
#endif
1198
1132
}
1199
1133
1200
- inline void Popen::kill (int sig_num)
1201
- {
1202
- #ifdef __USING_WINDOWS__
1203
- if (!TerminateProcess (this ->process_handle_ , (UINT)sig_num)) {
1204
- throw OSError (" TerminateProcess" , 0 );
1205
- }
1206
- #else
1207
- ::kill (child_pid_, sig_num);
1208
- #endif
1209
- }
1210
-
1211
-
1212
1134
inline void Popen::execute_process () noexcept (false )
1213
1135
{
1214
1136
#ifdef __USING_WINDOWS__
0 commit comments