| 1755 | */ |
| 1756 | template <typename C, typename T> |
| 1757 | int |
| 1758 | basic_pstreambuf<C,T>::wait(bool nohang) |
| 1759 | { |
| 1760 | int child_exited = -1; |
| 1761 | if (is_open()) |
| 1762 | { |
| 1763 | int exit_status; |
| 1764 | switch(::waitpid(ppid_, &exit_status, nohang ? WNOHANG : 0)) |
| 1765 | { |
| 1766 | case 0 : |
| 1767 | // nohang was true and process has not exited |
| 1768 | child_exited = 0; |
| 1769 | break; |
| 1770 | case -1 : |
| 1771 | error_ = errno; |
| 1772 | break; |
| 1773 | default : |
| 1774 | // process has exited |
| 1775 | ppid_ = 0; |
| 1776 | status_ = exit_status; |
| 1777 | child_exited = 1; |
| 1778 | // Close wpipe, would get SIGPIPE if we used it. |
| 1779 | destroy_buffers(pstdin); |
| 1780 | close_fd(wpipe_); |
| 1781 | // Must free read buffers and pipes on destruction |
| 1782 | // or next call to open()/close() |
| 1783 | break; |
| 1784 | } |
| 1785 | } |
| 1786 | return child_exited; |
| 1787 | } |
| 1788 | |
| 1789 | /** |
| 1790 | * Sends the specified signal to the process. A signal can be used to |