What are you trying to achieve?

If the user is controlling this via the keyboard, then they must be able to see the output on the screen. And if the output from the child process is going to the screen, Ctrl-S will pause and resume it without the parent process needing to do anything. If you are capturing the output from the child in the parent and then printing it to the screen, then Ctrl-S will work just as it always does.

If the output isn't going to the screen, then how would then user decide when to pause or resume?

The point is that Ctrl-S doesn't "signal" the program in anyway at all. It simply causes the console device to stop accepting output. The program continues running until the output buffer is full, and then the print blocks until the buffer gets emptied.

BTW. Ctrl-Q is a misnomer here. After a Ctrl-S pause, any key* will resume output.

*Except Ctrl-C or ctrl-Break which would interupt the program.

However, if no console output is involved and your purpose is simply to have the parent process pause and resume the child process (ie. without user interaction), then use Win32::Process to start the child and use its Suspend() & Resume() methods.

I guess the third possibility is that your parent process is capturing the output from the child process via a pipe and you want to be able to tell the child to stop producing output temporarially. And then the answer is to just stop reading. The pipe buffer will fill and the child will effectively be suspended until you start reading again.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: How to intercept ctrl-S/ctrl-Q characters from STDIN by BrowserUk
in thread How to intercept ctrl-S/ctrl-Q characters from STDIN by JohnBurley

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.