@@ -902,17 +902,9 @@ class Streams
902902 * Command provided in a single string.
903903 * wait() - Wait for the child to exit.
904904 * retcode() - The return code of the exited child.
905- * pid() - PID of the spawned child.
906- * poll() - Check the status of the running child.
907905 * send(...) - Send input to the input channel of the child.
908906 * communicate(...) - Get the output/error from the child and close the channels
909907 * 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.
916908 */
917909class Popen
918910{
@@ -956,14 +948,10 @@ class Popen
956948 execute_process ();
957949 }
958950
959- int pid () const noexcept { return child_pid_; }
960-
961951 int retcode () const noexcept { return retcode_; }
962952
963953 int wait () noexcept (false );
964954
965- int poll () noexcept (false );
966-
967955 void set_out_buf_cap (size_t cap) { stream_.set_out_buf_cap (cap); }
968956
969957 void set_err_buf_cap (size_t cap) { stream_.set_err_buf_cap (cap); }
@@ -1001,15 +989,6 @@ class Popen
1001989 return communicate (nullptr , 0 );
1002990 }
1003991
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-
1013992private:
1014993 template <typename F, typename ... Args>
1015994 void init_args (F&& farg, Args&&... args);
@@ -1033,7 +1012,6 @@ class Popen
10331012 std::vector<std::string> vargs_;
10341013 std::vector<char *> cargv_;
10351014
1036- bool child_created_ = false ;
10371015 // Pid of the child process
10381016 int child_pid_ = -1 ;
10391017
@@ -1068,7 +1046,7 @@ inline int Popen::wait() noexcept(false)
10681046 return 0 ;
10691047#else
10701048 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_ );
10721050 if (ret == -1 ) {
10731051 if (errno != ECHILD) throw OSError (" waitpid failed" , errno);
10741052 return 0 ;
@@ -1081,56 +1059,6 @@ inline int Popen::wait() noexcept(false)
10811059#endif
10821060}
10831061
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-
11341062inline void Popen::execute_process () noexcept (false )
11351063{
11361064#ifdef __USING_WINDOWS__
@@ -1233,8 +1161,6 @@ inline void Popen::execute_process() noexcept(false)
12331161 throw OSError (" fork failed" , errno);
12341162 }
12351163
1236- child_created_ = true ;
1237-
12381164 if (child_pid_ == 0 )
12391165 {
12401166 // Close descriptors belonging to parent
0 commit comments