Author: mturk Date: Fri Jan 15 10:57:46 2010 New Revision: 899590 URL: http://svn.apache.org/viewvc?rev=899590&view=rev Log: Check the status from parent write
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c?rev=899590&r1=899589&r2=899590&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Fri Jan 15 10:57:46 2010 @@ -488,7 +488,13 @@ } else { overlap[0].stat = 0; - WriteFile(ppipe[PIPE_STDOUT_RPC], overlap[0].buff, rd, &wr, NULL); + if (!WriteFile(ppipe[PIPE_STDOUT_RPC], + overlap[0].buff, rd, &wr, NULL)) { + /* Write to parent failed + */ + SAFE_CLOSE_HANDLE(pipes[PIPE_STDOUT_RDS]); + ResetEvent(overlap[0].o.hEvent); + } } rc = ACR_EINTR; break; @@ -498,13 +504,20 @@ &rd, (LPOVERLAPPED)&overlap[0]); if (iostat && rd != 0) { overlap[0].stat = 0; - WriteFile(ppipe[PIPE_STDOUT_RPC], overlap[0].buff, rd, &wr, NULL); - /* Issue another read */ - SetEvent(overlap[0].o.hEvent); + if (!WriteFile(ppipe[PIPE_STDOUT_RPC], + overlap[0].buff, rd, &wr, NULL)) { + /* Write to parent failed + */ + SAFE_CLOSE_HANDLE(pipes[PIPE_STDOUT_RDS]); + ResetEvent(overlap[0].o.hEvent); + } + else { + /* Issue another read */ + SetEvent(overlap[0].o.hEvent); + } } else { overlap[0].stat = GetLastError(); - ACR_DEBUG((THROW_FMARK, "RDFAIL STDOUT %d", overlap[0].stat)); if (overlap[0].stat != ERROR_IO_PENDING) { FlushFileBuffers(ppipe[PIPE_STDOUT_RPC]); SAFE_CLOSE_HANDLE(pipes[PIPE_STDOUT_RDS]); @@ -529,7 +542,13 @@ } else { overlap[1].stat = 0; - WriteFile(ppipe[PIPE_STDERR_RPC], overlap[1].buff, rd, &wr, NULL); + if (!WriteFile(ppipe[PIPE_STDERR_RPC], + overlap[1].buff, rd, &wr, NULL)) { + /* Write to parent failed + */ + SAFE_CLOSE_HANDLE(pipes[PIPE_STDOUT_RDS]); + ResetEvent(overlap[0].o.hEvent); + } } rc = ACR_EINTR; break; @@ -539,9 +558,17 @@ &rd, (LPOVERLAPPED)&overlap[1]); if (iostat && rd != 0) { overlap[1].stat = 0; - WriteFile(ppipe[PIPE_STDERR_RPC], overlap[1].buff, rd, &wr, NULL); - /* Issue another read */ - SetEvent(overlap[1].o.hEvent); + if (!WriteFile(ppipe[PIPE_STDERR_RPC], + overlap[1].buff, rd, &wr, NULL)) { + /* Write to parent failed + */ + SAFE_CLOSE_HANDLE(pipes[PIPE_STDERR_RDS]); + ResetEvent(overlap[1].o.hEvent); + } + else { + /* Issue another read */ + SetEvent(overlap[1].o.hEvent); + } } else { overlap[1].stat = GetLastError(); @@ -940,8 +967,6 @@ overlap[2].o.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); waithandle[waitn++] = overlap[2].o.hEvent; inpp = (const char *)ep->data.iov_base; - ACR_DEBUG((THROW_FMARK, "Has stdin %d", ep->data.iov_len)); - } rc = 0; @@ -1075,7 +1100,6 @@ iostat = WriteFile(childpipes[PIPE_STDINP_RPC], inpp, ep->data.iov_len, &wr, (LPOVERLAPPED)&overlap[2]); - ACR_DEBUG((THROW_FMARK, "Written %d", wr)); if (iostat && wr != 0) { ep->data.iov_len -= wr; inpp += wr;