This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: cygwin-2 process handling


On May 27 14:23, Corinna Vinschen wrote:
> Hi Takashi,
> 
> On May 21 20:53, Takashi Yano wrote:
> > [...]
> > +  if (output_handle_local)
> > +    {
> > +      OBJECT_BASIC_INFORMATION obi;
> > +      NTSTATUS status;
> > +      ULONG hdl_cnt = 0;
> > +
> > +      status = NtQueryObject (output_handle_local, ObjectBasicInformation,
> > +	  &obi, sizeof obi, NULL);
> > +      if (!NT_SUCCESS (status))
> > +	debug_printf ("NtQueryObject: %y", status);
> > +      else
> > +	hdl_cnt = obi.HandleCount;
> > +      termios_printf("HandleCount: %d", hdl_cnt);
> > +      if (hdl_cnt == 1)
> > +	SetEvent (input_available_event);
> > +      CloseHandle (output_handle_local);
> > +    }
>  
> Isn't that racy?  Consider two processes doing that at the same time.
> Both calls to NtQueryObject could come up with hdl_cnt == 2 and the
> problem persists.
> 
> Wouldn't it be safer to call SetEvent(input_available_event) all the
> time from here?

We discussed this already in March and only briefly talked about a
change like this requiring changes to fhandler_pty_slave::read.
However, I don't see this.  The read code already takes 0 bytes input
and broken pipe scenarios into account.  Do you see something needing
a change I don't?


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgp0vxgPYINAJ.pgp
Description: PGP signature


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