Sim, bash
usa waitpid()
com WNOHANG
em um loop. Você pode ver isso em waitchld()
in jobs.c
:
static int
waitchld (wpid, block)
pid_t wpid;
int block;
{
...
do
{
/* We don't want to be notified about jobs stopping if job control
is not active. XXX - was interactive_shell instead of job_control */
waitpid_flags = (job_control && subshell_environment == 0)
? (WUNTRACED|wcontinued)
: 0;
if (sigchld || block == 0)
waitpid_flags |= WNOHANG;
...
if (block == 1 && queue_sigchld == 0 && (waitpid_flags & WNOHANG) == 0)
{
internal_warning (_("waitchld: turning on WNOHANG to avoid indefinite block"));
waitpid_flags |= WNOHANG;
}
pid = WAITPID (-1, &status, waitpid_flags);
...
/* We have successfully recorded the useful information about this process
that has just changed state. If we notify asynchronously, and the job
that this process belongs to is no longer running, then notify the user
of that fact now. */
if (asynchronous_notification && interactive)
notify_of_job_status ();
return (children_exited);
}
A função notify_of_job_status()
simplesmente escreve para o bash
process 'stream de erro padrão.
Infelizmente, não posso dizer muito se a configuração de tostop
com stty
deve influenciar o shell em que você faz isso.