Sometimes I pipe articles in tin(1) through a perl script that parses the output, does something and pipes it into less; when I quit less I'm back in tin and everything is fine. However, when I press ctrl-z (happens more often than I'd think) the terminal ends up in a strange state. The output is

Stopped. Type 'fg' to restart tin

but I have no shell:

ls (nothing)

entering "fg" doesn't take me back to tin. Killing the perl and/or less processes doesn't help either, nor does pressing 'q' (as command for less or tin).

A tin developer analysed the behaviour of tin for me: before popen(), tin does (feed.c:feed_articles() ~ line 616)

reset_shell_mode(3ncurses); endwin(3ncurses);

and after pclose() (feed.c:feed_articles() ~ line 855)

reset_prog_mode(3ncurses); set_keypad_on(3ncurses);

SIGTSTP causes (signal.c:handle_suspend())

set_keypad_off(3ncurses); set_xclick_off(3ncurses); reset_shell_mode(3ncurses); kill(0, SIGSTOP); reset_prog_mode(3ncurses); set_keypad_on(3ncurses); set_xclick_on(3ncurses);

The developer claims that the double reset_shell_mode shouldn't hurt and that this looks ok (I think so as well).

He reduced my test case to

cat|less

and pressing ^Z, which works nicely, however piping through

perl -ne 'print $_;'|less

and pressing ^Z confuses perl. This looks like a perl-specific problem.

Can someone shed more light on this?


In reply to weird ctrl-z behaviour when piping from tin through perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.