@@ -902,17 +902,9 @@ class Streams
902
902
* Command provided in a single string.
903
903
* wait() - Wait for the child to exit.
904
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
905
* send(...) - Send input to the input channel of the child.
908
906
* communicate(...) - Get the output/error from the child and close the channels
909
907
* 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.
916
908
*/
917
909
class Popen
918
910
{
@@ -956,14 +948,10 @@ class Popen
956
948
execute_process ();
957
949
}
958
950
959
- int pid () const noexcept { return child_pid_; }
960
-
961
951
int retcode () const noexcept { return retcode_; }
962
952
963
953
int wait () noexcept (false );
964
954
965
- int poll () noexcept (false );
966
-
967
955
void set_out_buf_cap (size_t cap) { stream_.set_out_buf_cap (cap); }
968
956
969
957
void set_err_buf_cap (size_t cap) { stream_.set_err_buf_cap (cap); }
@@ -1001,15 +989,6 @@ class Popen
1001
989
return communicate (nullptr , 0 );
1002
990
}
1003
991
1004
- FILE* input () { return stream_.input (); }
1005
- FILE* output () { return stream_.output ();}
1006
- FILE* error () { return stream_.error (); }
1007
-
1008
- // / Stream close APIs
1009
- void close_input () { stream_.input_ .reset (); }
1010
- void close_output () { stream_.output_ .reset (); }
1011
- void close_error () { stream_.error_ .reset (); }
1012
-
1013
992
private:
1014
993
template <typename F, typename ... Args>
1015
994
void init_args (F&& farg, Args&&... args);
@@ -1033,7 +1012,6 @@ class Popen
1033
1012
std::vector<std::string> vargs_;
1034
1013
std::vector<char *> cargv_;
1035
1014
1036
- bool child_created_ = false ;
1037
1015
// Pid of the child process
1038
1016
int child_pid_ = -1 ;
1039
1017
@@ -1068,7 +1046,7 @@ inline int Popen::wait() noexcept(false)
1068
1046
return 0 ;
1069
1047
#else
1070
1048
int ret, status;
1071
- std::tie (ret, status) = util::wait_for_child_exit (pid () );
1049
+ std::tie (ret, status) = util::wait_for_child_exit (child_pid_ );
1072
1050
if (ret == -1 ) {
1073
1051
if (errno != ECHILD) throw OSError (" waitpid failed" , errno);
1074
1052
return 0 ;
@@ -1081,56 +1059,6 @@ inline int Popen::wait() noexcept(false)
1081
1059
#endif
1082
1060
}
1083
1061
1084
- inline int Popen::poll () noexcept (false )
1085
- {
1086
- #ifdef __USING_WINDOWS__
1087
- int ret = WaitForSingleObject (process_handle_, 0 );
1088
- if (ret != WAIT_OBJECT_0) return -1 ;
1089
-
1090
- DWORD dretcode_;
1091
- if (FALSE == GetExitCodeProcess (process_handle_, &dretcode_))
1092
- throw OSError (" GetExitCodeProcess" , 0 );
1093
-
1094
- retcode_ = (int )dretcode_;
1095
- CloseHandle (process_handle_);
1096
-
1097
- return retcode_;
1098
- #else
1099
- if (!child_created_) return -1 ; // TODO: ??
1100
-
1101
- int status;
1102
-
1103
- // Returns zero if child is still running
1104
- int ret = waitpid (child_pid_, &status, WNOHANG);
1105
- if (ret == 0 ) return -1 ;
1106
-
1107
- if (ret == child_pid_) {
1108
- if (WIFSIGNALED (status)) {
1109
- retcode_ = WTERMSIG (status);
1110
- } else if (WIFEXITED (status)) {
1111
- retcode_ = WEXITSTATUS (status);
1112
- } else {
1113
- retcode_ = 255 ;
1114
- }
1115
- return retcode_;
1116
- }
1117
-
1118
- if (ret == -1 ) {
1119
- // From subprocess.py
1120
- // This happens if SIGCHLD is set to be ignored
1121
- // or waiting for child process has otherwise been disabled
1122
- // for our process. This child is dead, we cannot get the
1123
- // status.
1124
- if (errno == ECHILD) retcode_ = 0 ;
1125
- else throw OSError (" waitpid failed" , errno);
1126
- } else {
1127
- retcode_ = ret;
1128
- }
1129
-
1130
- return retcode_;
1131
- #endif
1132
- }
1133
-
1134
1062
inline void Popen::execute_process () noexcept (false )
1135
1063
{
1136
1064
#ifdef __USING_WINDOWS__
@@ -1233,8 +1161,6 @@ inline void Popen::execute_process() noexcept(false)
1233
1161
throw OSError (" fork failed" , errno);
1234
1162
}
1235
1163
1236
- child_created_ = true ;
1237
-
1238
1164
if (child_pid_ == 0 )
1239
1165
{
1240
1166
// Close descriptors belonging to parent
0 commit comments