Abu Sa’eed narrated that he heard the Messenger of Allah (pbuh) say: “Let not two people who go out to the toilet (Gha’it) to relieve themselves (such that) their private parts are uncovered, talking to one another. Verily Allah, the Mighty and Sublime, hates that.” (Sunan Abu-Dawud volume 1, number 15)
Hudain bin Al-Mundhir said that Al-Muhajir bin Qunfudh came to the Prophet while he was urinating, and he greeted him with the Salam, but he did not respond to his greeting until he performed Wudu. He then excused himself (for the delay) by saying: “I disliked that I mention Allah – Exalted is His remembrance – except in a state of purity.” (Sunan-Abu-Dawud volume 1, number 17)
This narration shows the reason for the delay in replying, and accordingly that it is disliked to mention Allah in such circumstances, and it may be inferred that one should not greet or talk to a person who is relieving himself with the Salam.