| 743 | | if (-1 == waitpid(pid, &status, 0)) { |
|---|
| 744 | | log_error_write(srv, __FILE__, __LINE__, "ss", "waitpid failed:", strerror(errno)); |
|---|
| 745 | | } else if (WIFEXITED(status)) { |
|---|
| 746 | | int toread; |
|---|
| 747 | | /* read everything from client and paste it into the output */ |
|---|
| 748 | | |
|---|
| 749 | | while(1) { |
|---|
| 750 | | if (ioctl(from_exec_fds[0], FIONREAD, &toread)) { |
|---|
| 751 | | log_error_write(srv, __FILE__, __LINE__, "s", |
|---|
| 752 | | "unexpected end-of-file (perhaps the ssi-exec process died)"); |
|---|
| 753 | | return -1; |
|---|
| | 740 | do { |
|---|
| | 741 | if (-1 == waitpid(pid, &status, 0)) { |
|---|
| | 742 | if (errno == EINTR) { |
|---|
| | 743 | was_interrupted++; |
|---|
| | 744 | } else { |
|---|
| | 745 | was_interrupted = 0; |
|---|
| | 746 | log_error_write(srv, __FILE__, __LINE__, "ss", "waitpid failed:", strerror(errno)); |
|---|
| 755 | | |
|---|
| 756 | | if (toread > 0) { |
|---|
| 757 | | b = chunkqueue_get_append_buffer(con->write_queue); |
|---|
| 758 | | |
|---|
| 759 | | buffer_prepare_copy(b, toread + 1); |
|---|
| 760 | | |
|---|
| 761 | | if ((r = read(from_exec_fds[0], b->ptr, b->size - 1)) < 0) { |
|---|
| 762 | | /* read failed */ |
|---|
| | 748 | } else if (WIFEXITED(status)) { |
|---|
| | 749 | int toread; |
|---|
| | 750 | /* read everything from client and paste it into the output */ |
|---|
| | 751 | was_interrupted = 0; |
|---|
| | 752 | |
|---|
| | 753 | while(1) { |
|---|
| | 754 | if (ioctl(from_exec_fds[0], FIONREAD, &toread)) { |
|---|
| | 755 | log_error_write(srv, __FILE__, __LINE__, "s", |
|---|
| | 756 | "unexpected end-of-file (perhaps the ssi-exec process died)"); |
|---|
| | 757 | return -1; |
|---|
| | 758 | } |
|---|
| | 759 | |
|---|
| | 760 | if (toread > 0) { |
|---|
| | 761 | b = chunkqueue_get_append_buffer(con->write_queue); |
|---|
| | 762 | |
|---|
| | 763 | buffer_prepare_copy(b, toread + 1); |
|---|
| | 764 | |
|---|
| | 765 | if ((r = read(from_exec_fds[0], b->ptr, b->size - 1)) < 0) { |
|---|
| | 766 | /* read failed */ |
|---|
| | 767 | break; |
|---|
| | 768 | } else { |
|---|
| | 769 | b->used = r; |
|---|
| | 770 | b->ptr[b->used++] = '\0'; |
|---|
| | 771 | } |
|---|
| | 772 | } else { |
|---|