Yes, bash uses waitpid() with WNOHANG in a loop. You can see this in 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);
}
The notify_of_job_status() function simply writes to the bash process' standard error stream.
I can't unfortunately say much about whether setting tostop with stty should influence the shell that you do this in.