'rsync --progress' always prints the dynamic progress information, even if the
process is suspended and backgrounded or rsync is started in the background.
This causes the display of the current foreground process on the tty (or shell)
to be scrambled every second as the progress bar is updated.
The solution is to use tcgetpgrp() (on stdout) to verify that rsync is the
foreground process. I'll provide a patch.
Created attachment 828 [details]
Created attachment 843 [details]
My version of the patch to progress.c
I'm considering this change, and I think it looks good with a couple changes to
the progress.c part of the patch:
- Make use of the HAVE_GETPGRP define.
- Don't skip the output if tcgetpgrp() returns -1 (as it will
if output is redirected to a file).
Is it safe to assume that if a system has getpgrp() that it also has
tcgetpgrp()? That's what both our patches are currently doing, and it seems
reasonable to me.
I've treated having getpgrp() as having tcgetpgrp() in my own code.
However, it may be safer to add a separate autoconf check, and only enable this
functionality #if HAVE_GETPGRP && HAVE_TCGETPGRP.
This was checked into the CVS version a little while ago.