What is the purpose of delayed suspend (Ctrl-Y) in Bash?

From the 4BSD manual for csh:

A ^Z takes effect immediately and is like an interrupt in that pending output and unread input are discarded when it is typed. There is another special key ^Y which does not generate a STOP signal until a program attempts to read(2) it. This can usefully be typed ahead when you have prepared some commands for a job which you wish to stop after it has read them.

So, the purpose is to type multiple inputs while the first one is being processed, and have the job stop after they are done.


Say there's a loop reading input and executing. It may be useful to let the task finish the current instruction it computes, without interrupting it before it gets back to the command line for a new one. So thus to end a cycle. This ends the loop gracefully and prevents it from running again if read is under a timeout restriction.


I can think of one scenario where it might be useful, but it's something of a contrived edge-case.

Suppose you're debugging a script that is writing temporary files that you wish to analyze before they're deleted as part of a clean-up routine.

You could add a read foo somewhere after the files are written (but before the cleanup), run the script, and press Ctrl-Y as they're being generated. You will then be dropped to a prompt with the script suspended in the background to do whatever you need to do, and can then fg to allow the script to complete.