This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: close-on-exec handles are left open by exec parent


On Thu, Aug 02, 2001 at 06:38:38PM +0400, egor duda wrote:
>Hi!
>
>  here's the proposed patch. it also contains a fix FreeConsole ()
>related bug -- when cygwin application frees its console,
>"process_input" thread may be still running. When console is closed,
>WaitForMultipleObjects () with console handle returns WAIT_FAILED, so
>"process_input" thread starts cycling and eating CPU.

Ack! I don't understand why you've introduced another synchronization
event.  Why not just close all of the fds after the program has been
successfully executed?  Once CreateProcess has executed, the handles will
be opened by the new process.

I really don't want to have YA synchronization point between the parent
and the child.  It seems like that will cause a hang with spawn P_NOWAIT
of a non-cygwin process which is something that I'm currently trying to
fix.

Now that I think of it, removed a close_all_files call from spawn.cc a
while ago.  I think that I thought that it was slowing things down.  Or,
maybe it was causing api_fatal to stop printing anything.  However, I'd
rather have a correctly working program for now and worry about api_fatal
later, so, I propose the (untested) patch below which puts the close_all_files
back.

Doesn't this solve the problem?

cgf
Index: spawn.cc
===================================================================
RCS file: /cvs/uberbaum/winsup/cygwin/spawn.cc,v
retrieving revision 1.83
diff -p -r1.83 spawn.cc
*** spawn.cc	2001/07/26 19:22:24	1.83
--- spawn.cc	2001/08/03 15:29:49
*************** skip_arg_parsing:
*** 675,681 ****
    MALLOC_CHECK;
    if (envblock)
      free (envblock);
!   ForceCloseHandle1 (ciresrv.cygheap_h, passed_cygheap_h);
    MALLOC_CHECK;
  
    /* Set errno now so that debugging messages from it appear before our
--- 675,681 ----
    MALLOC_CHECK;
    if (envblock)
      free (envblock);
!   cygheap_setup_for_child_cleanup (&ciresrv);
    MALLOC_CHECK;
  
    /* Set errno now so that debugging messages from it appear before our
*************** skip_arg_parsing:
*** 718,723 ****
--- 718,724 ----
        strace.execing = 1;
        hExeced = pi.hProcess;
        strcpy (myself->progname, real_path);
+       close_all_files ();
      }
    else
      {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]