* sudo & runs sudo as a background process. The shell and
sudo race to each print their prompt.
* sudo tries to read the password from the terminal. At
this point it receives a SIGTSTP from the kernel tty subsystem
due to the terminal having the ttin flag set (ie, issue TSTP on
terminal input attempt by background process group).
* if you're lucky your shell will print a message about this
immediately, but this is not guaranteed. And in any case it is
confusing.
The solution is that sudo ought to make a non-blocking read of its
terminal _before_ printing the prompt. Then, sudo would get SIGTSTP
straight away and you'd see this:
What is happening here is this:
* sudo & runs sudo as a background process. The shell and
sudo race to each print their prompt.
* sudo tries to read the password from the terminal. At
this point it receives a SIGTSTP from the kernel tty subsystem
due to the terminal having the ttin flag set (ie, issue TSTP on
terminal input attempt by background process group).
* if you're lucky your shell will print a message about this
immediately, but this is not guaranteed. And in any case it is
confusing.
The solution is that sudo ought to make a non-blocking read of its
terminal _before_ printing the prompt. Then, sudo would get SIGTSTP
straight away and you'd see this:
ian@anarres:~ $ sudo bash &
[1] 7745
ian@anarres:~ $
[1]+ Stopped sudo bash
ian@anarres:~ $
This change ought to be made in whatever library sudo is using for
password prompting.
Ian.