Skip to content

Commit 9e1ccf5

Browse files
committed
refactor, subprocess: Remove unused Popen::poll()
1 parent 24b53fc commit 9e1ccf5

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

src/util/subprocess.h

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,6 @@ 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-
* poll() - Check the status of the running child.
906905
* send(...) - Send input to the input channel of the child.
907906
* communicate(...) - Get the output/error from the child and close the channels
908907
* from the parent side.
@@ -959,8 +958,6 @@ class Popen
959958

960959
int wait() noexcept(false);
961960

962-
int poll() noexcept(false);
963-
964961
void set_out_buf_cap(size_t cap) { stream_.set_out_buf_cap(cap); }
965962

966963
void set_err_buf_cap(size_t cap) { stream_.set_err_buf_cap(cap); }
@@ -1078,56 +1075,6 @@ inline int Popen::wait() noexcept(false)
10781075
#endif
10791076
}
10801077

1081-
inline int Popen::poll() noexcept(false)
1082-
{
1083-
#ifdef __USING_WINDOWS__
1084-
int ret = WaitForSingleObject(process_handle_, 0);
1085-
if (ret != WAIT_OBJECT_0) return -1;
1086-
1087-
DWORD dretcode_;
1088-
if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
1089-
throw OSError("GetExitCodeProcess", 0);
1090-
1091-
retcode_ = (int)dretcode_;
1092-
CloseHandle(process_handle_);
1093-
1094-
return retcode_;
1095-
#else
1096-
if (!child_created_) return -1; // TODO: ??
1097-
1098-
int status;
1099-
1100-
// Returns zero if child is still running
1101-
int ret = waitpid(child_pid_, &status, WNOHANG);
1102-
if (ret == 0) return -1;
1103-
1104-
if (ret == child_pid_) {
1105-
if (WIFSIGNALED(status)) {
1106-
retcode_ = WTERMSIG(status);
1107-
} else if (WIFEXITED(status)) {
1108-
retcode_ = WEXITSTATUS(status);
1109-
} else {
1110-
retcode_ = 255;
1111-
}
1112-
return retcode_;
1113-
}
1114-
1115-
if (ret == -1) {
1116-
// From subprocess.py
1117-
// This happens if SIGCHLD is set to be ignored
1118-
// or waiting for child process has otherwise been disabled
1119-
// for our process. This child is dead, we cannot get the
1120-
// status.
1121-
if (errno == ECHILD) retcode_ = 0;
1122-
else throw OSError("waitpid failed", errno);
1123-
} else {
1124-
retcode_ = ret;
1125-
}
1126-
1127-
return retcode_;
1128-
#endif
1129-
}
1130-
11311078
inline void Popen::execute_process() noexcept(false)
11321079
{
11331080
#ifdef __USING_WINDOWS__

0 commit comments

Comments
 (0)