retry.py: bypass a lot of unneeded hairy code by just passing the tty
down. From the commentary on the SO question
(http://stackoverflow.com/questions/15200700/how-do-i-set-the-terminal-foreground-process-group-for-a-process-im-running-und/15257702?noredirect=1#):

"The setpgrp() call creates a new process group in the same session,
so that the new process will receive any ctrl-c/ctrl-z/etc from the
user, and your retry script won't. Then the tcsetpgrp() makes the new
process group be the foreground one on the controlling tty. The new
process gets a SIGTTOU when that happens (because since the setpgrp(),
it has been in a background process group), which normally would make
the process stop, so that's the reason for ignoring SIGTTOU. We set
the SIGTTOU handler back to whatever it was before, to minimize the
chance of the subprocess being confused by an unexpected signal table.
Since the subprocess is now in the foreground group for the tty, its
tcgetpgrp() and getpgrp() will be the same, and isatty(1) will be true
(assuming the stdout it inherits from retry.py actually is a tty). You
don't need to proxy traffic between the subprocess and the tty, which
lets you ditch all the select event handling and
fcntl-nonblocking-setting."

Thanks to "thepaul" :-)