in reply to How to intercept ctrl-S/ctrl-Q characters from STDIN
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to intercept ctrl-S/ctrl-Q characters from STDIN
by JohnBurley (Initiate) on Aug 22, 2008 at 18:51 UTC | |
|
Re^2: How to intercept ctrl-S/ctrl-Q characters from STDIN
by Mr. Muskrat (Canon) on Aug 21, 2008 at 17:41 UTC | |
by BrowserUk (Patriarch) on Aug 21, 2008 at 17:55 UTC | |
by Mr. Muskrat (Canon) on Aug 22, 2008 at 14:56 UTC | |
by BrowserUk (Patriarch) on Aug 22, 2008 at 15:14 UTC |