From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4491 invoked by alias); 19 Apr 2007 13:08:20 -0000 Received: (qmail 4482 invoked by uid 22791); 19 Apr 2007 13:08:19 -0000 X-Spam-Check-By: sourceware.org Received: from province.act-europe.fr (HELO province.act-europe.fr) (212.157.227.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 19 Apr 2007 14:08:16 +0100 Received: by province.act-europe.fr (Postfix, from userid 560) id 805E516542F; Thu, 19 Apr 2007 15:08:07 +0200 (CEST) Date: Thu, 19 Apr 2007 14:16:00 -0000 From: Jerome Guitton To: gdb-patches@sources.redhat.com Subject: Re: [RFA/mingw32] stdin redirection Message-ID: <20070419130807.GB70722@adacore.com> References: <20070419122008.GA27914@adacore.com> <20070419122637.GA26372@caradoc.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20070419122637.GA26372@caradoc.them.org> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00293.txt.bz2 --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 190 Daniel Jacobowitz (drow@false.org): > I assume you meant to delete the code at the bottom and the retry > label. OK with that change. Right, thanks. Applied (final patch in attachement). --AhhlLboLdkugWU4S Content-Type: video/dv Content-Disposition: attachment; filename="ser-mingw.c.dif" Content-Transfer-Encoding: quoted-printable Content-length: 3404 Index: ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/ChangeLog,v=0A= retrieving revision 1.8296=0A= diff -u -r1.8296 ChangeLog=0A= --- ChangeLog 18 Apr 2007 13:25:03 -0000 1.8296=0A= +++ ChangeLog 19 Apr 2007 13:04:03 -0000=0A= @@ -1,3 +1,9 @@=0A= +2007-04-19 Jerome Guitton =0A= +=0A= + * ser-mingw.c (fd_is_file): New function.=0A= + (file_select_thread): New function.=0A= + (ser_console_wait_handle): Add special handling for files.=0A= +=0A= 2007-04-18 Denis Pilat =0A= =20=0A= * dwarf2read.c (read_subrange_type): Use DW_ATE_signed default type=0A= Index: ser-mingw.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/ser-mingw.c,v=0A= retrieving revision 1.8=0A= diff -u -r1.8 ser-mingw.c=0A= --- ser-mingw.c 8 Apr 2007 15:20:07 -0000 1.8=0A= +++ ser-mingw.c 19 Apr 2007 13:04:03 -0000=0A= @@ -453,6 +453,15 @@=0A= return 0;=0A= }=0A= =20=0A= +static int=0A= +fd_is_file (int fd)=0A= +{=0A= + if (GetFileType ((HANDLE) _get_osfhandle (fd)) =3D=3D FILE_TYPE_DISK)=0A= + return 1;=0A= + else=0A= + return 0;=0A= +}=0A= +=0A= static DWORD WINAPI=0A= pipe_select_thread (void *arg)=0A= {=0A= @@ -501,6 +510,42 @@=0A= }=0A= }=0A= =20=0A= +static DWORD WINAPI=0A= +file_select_thread (void *arg)=0A= +{=0A= + struct serial *scb =3D arg;=0A= + struct ser_console_state *state;=0A= + int event_index;=0A= + HANDLE h;=0A= +=0A= + state =3D scb->state;=0A= + h =3D (HANDLE) _get_osfhandle (scb->fd);=0A= +=0A= + while (1)=0A= + {=0A= + HANDLE wait_events[2];=0A= + DWORD n_avail;=0A= +=0A= + SetEvent (state->have_stopped);=0A= +=0A= + wait_events[0] =3D state->start_select;=0A= + wait_events[1] =3D state->exit_select;=0A= +=0A= + if (WaitForMultipleObjects (2, wait_events, FALSE, INFINITE) !=3D WA= IT_OBJECT_0)=0A= + return 0;=0A= +=0A= + ResetEvent (state->have_stopped);=0A= +=0A= + if (SetFilePointer (h, 0, NULL, FILE_CURRENT) =3D=3D INVALID_SET_FIL= E_POINTER)=0A= + {=0A= + SetEvent (state->except_event);=0A= + continue;=0A= + }=0A= +=0A= + SetEvent (state->read_event);=0A= + }=0A= +}=0A= +=0A= static void=0A= ser_console_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except)= =0A= {=0A= @@ -512,7 +557,7 @@=0A= int is_tty;=0A= =20=0A= is_tty =3D isatty (scb->fd);=0A= - if (!is_tty && !fd_is_pipe (scb->fd))=0A= + if (!is_tty && !fd_is_file (scb->fd) && !fd_is_pipe (scb->fd))=0A= {=0A= *read =3D NULL;=0A= *except =3D NULL;=0A= @@ -541,9 +586,12 @@=0A= if (is_tty)=0A= state->thread =3D CreateThread (NULL, 0, console_select_thread, scb, 0,= =0A= &threadId);=0A= - else=0A= + else if (fd_is_pipe (scb->fd))=0A= state->thread =3D CreateThread (NULL, 0, pipe_select_thread, scb, 0,=0A= &threadId);=0A= + else=0A= + state->thread =3D CreateThread (NULL, 0, file_select_thread, scb, 0,=0A= + &threadId);=0A= }=0A= =20=0A= *read =3D state->read_event;=0A= --AhhlLboLdkugWU4S--