It sounds like what you are describing is actually program A running in the background. A process can still print to the terminal even if it is running in the background.
A bash example:
#----background_program----#
#!/bin/bash
for ((i=0;i<=10;i++)); do
echo "$i"
sleep 5
done
exit 0
You can run this in the background, see its output popping up on your terminal. After the first output message, your cursor is moved off the prompt. You can then execute other commands in the foreground whilst background_program
is still executing:
./background_program & # '&' to put in background
echo "wut"
echo "foo"
echo "bar"
This will give you something like:
sandbox@Dionysus:~$ ./background_program &
[1] 6197
sandbox@Dionysus:~$ 0
echo "wut"
wut
sandbox@Dionysus:~$ 1
echo "foo"
foo
sandbox@Dionysus:~$ 2
echo "bar"
bar
sandbox@Dionysus:~$ 3
4
5
6
7
8
9
10
I did this in a gnome-terminal but I don't think the behavior is uncommon.
If you were to execute your program A in the foreground, you get exactly what @Stephen said, typeahead. The program is not executed as your command is loaded in the buffer and then interpreted after program A completes.