This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

RFA: Fix for piped input on Linux



I'm not sure if piping input to GDB is all that common, but I happened
to encounter an odd little glitch on my RedHat Linux 6.2 setup 
(2.2.16-3 i686) that causes GDB to receive bogus SIGHUPs on input.  The
following works for me, but someone who actually understands the real
semantics of the flags ought to comment.  The symptom encountered is
that

	gdb foo < script

works just fine, but

	cat script | gdb foo

(for example) fails with messages such as

      (gdb) Hangup detected on fd 0
      error detected on stdin

without reading a single complete command.  With the change, one gets the
message above only at EOF, where it makes a little more sense.

Paul Hilfinger


2001-05-08  Paul N. Hilfinger  <hilfingr@otisco.mckusick.com>

ChangeLog:

	* event-loop.c (handle_file_event): Mask off POLLHUP when we receive
	input.  For some reason, Redhat Linux 6.2 (at least) sets the POLLHUP
	bit on each input when reading from a pipe (not from a file).  

diff -c -3 -p -r1.16 event-loop.c
*** event-loop.c	2001/03/27 20:36:23	1.16
--- event-loop.c	2001/05/08 22:38:07
*************** handle_file_event (int event_file_desc)
*** 662,667 ****
--- 662,674 ----
  	  if (use_poll)
  	    {
  #ifdef HAVE_POLL
+ 	      /* The following two lines address a problem seen on at
+ 	         least one Linux version (RedHat 6.2): when input
+ 	         comes from a pipe, the POLLHUP flag is set on each 
+ 		 input, so in the event we are expecting input and get
+ 	         it, we turn off POLLHUP. */		 
+ 	      if (file_ptr->ready_mask & file_ptr->mask & POLLIN)
+ 		file_ptr->ready_mask &= ~POLLHUP;
  	      error_mask = POLLHUP | POLLERR | POLLNVAL;
  	      mask = (file_ptr->ready_mask & file_ptr->mask) |
  		(file_ptr->ready_mask & error_mask);


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