pty/tty or signal strangeness, or grep/bsdgrep bug?

Jeremy Chadwick jdc at koitsu.org
Tue Oct 23 14:27:04 UTC 2012


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 at koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Mountain View, CA, US                                            |
| Making life hard for others since 1977.             PGP 4BD6C0CB |



More information about the freebsd-stable mailing list