Mac – Weird null characters ^@ output on iTerm 2 / zsh when a command is running

itermmacterminalzsh

When I m using iTerm 2 (with zsh), and a command is running at the prompt, every minute or so ^@ (NULL character) got displayed on the terminal. Below is an example, using socat, but other commands yield the same outcome:

2016/03/11 09:59:36 socat[1514] D data loop: sock1->eof=0, sock2->eof=0, closing=0, wasaction=1, total_to={0.000000}
2016/03/11 09:59:36 socat[1514] D select(8, &0xa0, &0x0, &0x0, NULL/0.000000)
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

In this example, ^@ is written at the end of the last line every minute or so.

If I run the same command with the built in mac os Terminal app / bash, the output is clean.

Any idea where these nulls characters comes from and how to get rid of it?

Best Answer

Null characters are anti-idle feature to keep connection alive with old servers.

Go to iTerm2 -> Preferences -> Profiles -> [select your profile] -> Session tab -> uncheck "When idle, send ASCII code" checkbox.