[PATCH] Cleanup: Close handles in script.cc:run()

Igor Pechtchanski pechtcha@cs.nyu.edu
Sat Mar 15 19:20:00 GMT 2003


On Sat, 15 Mar 2003, Max Bowsher wrote:

> Pavel Tsekov wrote:
> > On Sat, 15 Mar 2003, Igor Pechtchanski wrote:
> >
> >> The attached patch closes the unneeded handles in run() in script.cc.
> >> Those handles should be closed according to
> >> <http://msdn.microsoft.com/library/en-us/dllproc/base/createprocess.asp>:
> >
> >    if (b)
> >      WaitForSingleObject (pi.hProcess, INFINITE);
> > +
> > +  CloseHandle(pi.hProcess);
> > +  CloseHandle(pi.hThread);
> >  }
> >
> > I guess it doesn't matter actually, but isn't it better to close the
> > thread handle before the process handle ?!
>
> Probably not better, but it feels nicer.
> Max.

I don't think it matters, but I agree with Max.  New version attached.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune
-------------- next part --------------
Index: script.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/script.cc,v
retrieving revision 2.4
diff -u -p -r2.4 script.cc
--- script.cc	18 Feb 2002 13:53:07 -0000	2.4
+++ script.cc	15 Mar 2003 16:37:59 -0000
@@ -98,6 +98,9 @@ run (const char *sh, const char *args, c
 
   if (b)
     WaitForSingleObject (pi.hProcess, INFINITE);
+
+  CloseHandle(pi.hThread);
+  CloseHandle(pi.hProcess);
 }
 
 void


More information about the Cygwin-apps mailing list