733 if(p->err[0] != -1) { |
730 if(p->err[0] != -1) { |
734 system_close(p->err[0]); |
731 system_close(p->err[0]); |
735 } |
732 } |
736 if(p->err[1] != -1) { |
733 if(p->err[1] != -1) { |
737 system_close(p->err[1]); |
734 system_close(p->err[1]); |
|
735 } |
|
736 |
|
737 // TODO: Because of WNOHANG, waitpid could fail and the process |
|
738 // is still running. In that case, another waitpid call should |
|
739 // be done later somewhere. |
|
740 int status = -1; |
|
741 if(waitpid(p->pid, &status, WNOHANG) == 0) { |
|
742 log_ereport(LOG_DEBUG, "cgi_close: waitpid returned 0: pid: %d", (int)p->pid); |
|
743 // cgi process still running |
|
744 // workaround: sleep 1 sec and try again, if that fails again |
|
745 sleep(1); |
|
746 if(waitpid(p->pid, &status, WNOHANG) == 0) { |
|
747 log_ereport(LOG_DEBUG, "cgi_close: waitpid returned 0 again: pid: %d", (int)p->pid); |
|
748 } |
738 } |
749 } |
739 |
750 |
740 return status; |
751 return status; |
741 } |
752 } |
742 |
753 |