From owner-freebsd-stable@FreeBSD.ORG Tue Oct 23 14:27:04 2012 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B82305C4 for ; Tue, 23 Oct 2012 14:27:04 +0000 (UTC) (envelope-from jdc@koitsu.strangled.net) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:16]) by mx1.freebsd.org (Postfix) with ESMTP id 9808B8FC14 for ; Tue, 23 Oct 2012 14:27:04 +0000 (UTC) Received: from omta12.emeryville.ca.mail.comcast.net ([76.96.30.44]) by qmta01.emeryville.ca.mail.comcast.net with comcast id EcTs1k0070x6nqcA1eT4Z3; Tue, 23 Oct 2012 14:27:04 +0000 Received: from koitsu.strangled.net ([67.180.84.87]) by omta12.emeryville.ca.mail.comcast.net with comcast id EeT31k0071t3BNj8YeT3lm; Tue, 23 Oct 2012 14:27:03 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 1960173A1A; Tue, 23 Oct 2012 07:27:03 -0700 (PDT) Date: Tue, 23 Oct 2012 07:27:03 -0700 From: Jeremy Chadwick To: freebsd-stable@freebsd.org Subject: pty/tty or signal strangeness, or grep/bsdgrep bug? Message-ID: <20121023142703.GA79098@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: kib@freebsd.org, ed@freebsd.org, jhb@freebsd.org X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2012 14:27:04 -0000 Please keep me CC'd as I'm not subscribed to the list. Something "fun" today. First off: yes, I should have been using 'bsdgrep -r -- "-2011" .', and yes that works fine, but that's besides the point. Here we go: % bsdgrep -r "-2011" . ^Z Suspended % bg [1] bsdgrep -r -2011 . & % qqqqqqqqqqq % % fg(standard input):qqqqqqqqqfgfg bsdgrep -r -2011 . ^C % Let me explain what transpired from an input perspective: 1. Ran bsdgrep -r "-2011" . 2. Pressed Ctrl-Z 3. Typed bg 4. Typed "q" 20 times in a row exactly 5. Pressed Ctrl-C 6. Typed "fg" and pressed Enter 7. Typed "ffgg" and pressed Enter 8. Pressed Ctrl-Z and Enter 9. Pressed Ctrl-C What's going on here? Where is the famous "Suspended (tty input)"? It gets more interesting. Here's another one: % bsdgrep -r "-2011" . ^Z Suspended % bg [1] bsdgrep -r -2011 . & % g(standard input):f fg gfg: Command not found. [1] + Suspended (tty input) bsdgrep -r -2011 . % jobs [1] + Suspended (tty input) bsdgrep -r -2011 . % fg bsdgrep -r -2011 . % And what transpired input-wise: 1. Ran bsdgrep -r "-2011" . 2. Pressed Ctrl-Z 3. Typed bg 4. Typed "fg" and Enter 5. Typed "fg" again and pressed Enter 6. Typed "jobs" and pressed Enter 7. Typed "fg" and pressed Enter 8. Pressed Ctrl-D Some facts: - Fully 100% reproducible - Tested only on RELENG_9 (source from 2012/10/21) - Happens regardless of shell (bash and csh tested; csh w/out dot files) - Similar behaviour happens with our base system grep (GNU grep) but sometimes it manifests itself in a weirder way - bsdgrep and GNU grep are both in state "ttyin" when this happens CC'ing some folks who might have some ideas or can explain how to troubleshoot this one. For the signal part, I believe this would be SIGTTIN. -- | Jeremy Chadwick jdc@koitsu.org | | UNIX Systems Administrator http://jdc.koitsu.org/ | | Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB |