You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@hyperreal.org on 2000/01/28 03:24:17 UTC

cvs commit: apache-2.0/src/lib/apr/threadproc/win32 proc.c

stoddard    00/01/27 18:24:16

  Modified:    src/lib/apr/threadproc/win32 proc.c
  Log:
  Fix some return codes and leave the new process handle open. In general,
  the parent process should explicitly close the handle if it does not need
  it. And Apache requires the handle for free_proc_chain clean-up processing.
  
  Revision  Changes    Path
  1.15      +3 -6      apache-2.0/src/lib/apr/threadproc/win32/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/win32/proc.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- proc.c	1999/12/16 13:14:56	1.14
  +++ proc.c	2000/01/28 02:24:15	1.15
  @@ -364,9 +364,6 @@
   
       if (CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, pEnvBlock, attr->currdir, 
                         &attr->si, &(*new)->pi)) {
  -        if (attr->detached) {
  -            CloseHandle((*new)->pi.hProcess);
  -        }
           if (attr->child_in) {
               ap_close(attr->child_in);
           }
  @@ -404,7 +401,7 @@
   ap_status_t ap_wait_proc(struct proc_t *proc, 
                            ap_wait_how_e wait)
   {
  -    pid_t stat;
  +    DWORD stat;
       if (!proc)
           return APR_ENOPROC;
       if (wait == APR_WAIT) {
  @@ -414,7 +411,7 @@
           else if (stat == WAIT_TIMEOUT) {
               return APR_CHILD_NOTDONE;
           }
  -        return APR_EEXIST;
  +        return GetLastError();
       }
       if ((stat = WaitForSingleObject(proc->pi.hProcess, 0)) == WAIT_OBJECT_0) {
           return APR_CHILD_DONE;
  @@ -422,7 +419,7 @@
       else if (stat == WAIT_TIMEOUT) {
           return APR_CHILD_NOTDONE;
       }
  -    return APR_EEXIST;
  +    return GetLastError();
   }
   
   ap_status_t ap_get_procdata(char *key, void *data, struct proc_t *proc)
  
  
  

Re: cvs commit: apache-2.0/src/lib/apr/threadproc/win32 proc.c

Posted by Bill Stoddard <st...@raleigh.ibm.com>.

> >   Fix some return codes and leave the new process handle open. In
general,
> >   the parent process should explicitly close the handle if it does not
need
> >   it. And Apache requires the handle for free_proc_chain clean-up
processing.
> >
> >   Revision  Changes    Path
> >        if (CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, pEnvBlock,
attr->currdir,
> >                          &attr->si, &(*new)->pi)) {
> >   -        if (attr->detached) {
> >   -            CloseHandle((*new)->pi.hProcess);
> >   -        }
> >            if (attr->child_in) {
> >                ap_close(attr->child_in);
> >            }
>
> If we want to keep the process handle open, shouldn't we just be not
> opening the file detached?  I don't have the answer with me, but ISTR a
> peice of code from Apache 1.3 (or somewhere) that closed the handle when
> detaching the process.
>
I think all the std handle redirection stuff will not work if the process is
not created detached. And I think Apache 1.3 may have been broken in this
regard as well. There are reports of CGI scripts not being terminated at
Apache shutdown. I plan to test this, just don't have the time to right now.

Bill


Re: cvs commit: apache-2.0/src/lib/apr/threadproc/win32 proc.c

Posted by rb...@apache.org.
>   Fix some return codes and leave the new process handle open. In general,
>   the parent process should explicitly close the handle if it does not need
>   it. And Apache requires the handle for free_proc_chain clean-up processing.
>   
>   Revision  Changes    Path
>        if (CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, pEnvBlock, attr->currdir, 
>                          &attr->si, &(*new)->pi)) {
>   -        if (attr->detached) {
>   -            CloseHandle((*new)->pi.hProcess);
>   -        }
>            if (attr->child_in) {
>                ap_close(attr->child_in);
>            }

If we want to keep the process handle open, shouldn't we just be not
opening the file detached?  I don't have the answer with me, but ISTR a
peice of code from Apache 1.3 (or somewhere) that closed the handle when
detaching the process.

Ryan



Come to the first official Apache Software Foundation
Conference!!!   <http://ApacheCon.Com/>

_______________________________________________________________________________
Ryan Bloom                        	rbb@ntrnet.net
2121 Stonehenge Dr. Apt #3
Raleigh, NC 27615		Ryan Bloom -- thinker, adventurer, artist,
				     writer, but mostly, friend.
-------------------------------------------------------------------------------


Re: cvs commit: apache-2.0/src/lib/apr/threadproc/win32 proc.c

Posted by rb...@apache.org.
>   Fix some return codes and leave the new process handle open. In general,
>   the parent process should explicitly close the handle if it does not need
>   it. And Apache requires the handle for free_proc_chain clean-up processing.
>   
>   Revision  Changes    Path
>        if (CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, pEnvBlock, attr->currdir, 
>                          &attr->si, &(*new)->pi)) {
>   -        if (attr->detached) {
>   -            CloseHandle((*new)->pi.hProcess);
>   -        }
>            if (attr->child_in) {
>                ap_close(attr->child_in);
>            }

If we want to keep the process handle open, shouldn't we just be not
opening the file detached?  I don't have the answer with me, but ISTR a
peice of code from Apache 1.3 (or somewhere) that closed the handle when
detaching the process.

Ryan



Come to the first official Apache Software Foundation
Conference!!!   <http://ApacheCon.Com/>

_______________________________________________________________________________
Ryan Bloom                        	rbb@ntrnet.net
2121 Stonehenge Dr. Apt #3
Raleigh, NC 27615		Ryan Bloom -- thinker, adventurer, artist,
				     writer, but mostly, friend.
-------------------------------------------------------------------------------