$ S_COLORS=never pidstat 4 3 > nocol.log
still has the bad chars
Further
$ S_COLORS=always pidstat 4 3 > withcol.log
Has what you'd expect from colors like "^[[0m^[[32;22m"
So detection is correct - the redirect runs in the no-color mode (unless forced by the environment variable), but the non colorized mode is the one that adds these broken extra "00" bytes.
$ S_COLORS=never pidstat 4 3 > nocol.log
still has the bad chars
Further
$ S_COLORS=always pidstat 4 3 > withcol.log
Has what you'd expect from colors like "^[[0m^[[32;22m"
So detection is correct - the redirect runs in the no-color mode (unless forced by the environment variable), but the non colorized mode is the one that adds these broken extra "00" bytes.