On Fri, 19 Mar 2021 13:58:40 +0100
Corinna Vinschen wrote:
> > extern "C" long
> > _get_osfhandle (int fd)
> > {
> >   long res;
> > 
> >   cygheap_fdget cfd (fd);
> >   if (cfd >= 0)
> >     {
> >       if (fd == 1 || fd == 2)
> >         res = (long) cfd->get_output_handle_cyg ();
> >       else
> >         res = (long) cfd->get_handle_cyg ();
> >     }
> >   else
> >     res = -1;
> > 
> >   syscall_printf ("%R = get_osfhandle(%d)", res, fd);
> >   return res;
> > }
> > 
> > ?
> 
> Maybe.  You introduced the "_cyg" handles, so you should know ;)
> 
> On a more serious note, this is, of course, a compatibility
> problem.  While _get_osfhandle is called by a Cygwin application,
> nobody knows what dubious actions that application will perform
> on this handle.  In all likelyhood, it fetched the handle to call
> Windows functions.  And *if* it does, wouldn't it make more sense
> if the non-Cygwin handle is returned?

You are right. If get_output_handle_cyg() is returned, OPOST
processing and charset conversion does not work. Thanks!
As for input, get_handle_cyg() should be returned rather than
get_handle() because reading from get_handle() will fail because
master writes input to cygwin handle for cygwin process.

-- 
Takashi Yano <takashi.y...@nifty.ne.jp>
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to