Fiqh-us-Sunnah Volume 002, Supererogatory Prayer, Fiqh 2.093.

Section : Praying when one needs to answer the call of nature and other things that may distract a person.

Thauban reports that the Messenger of Allah said: "There are three acts which are not allowed: For a person to lead a people in prayer and then make supplications for himself without including them, for then he would be dishonest to them; to look inside a house without obtaining permission, for if he does so (it is as if) he has already entered it (without permission); and to offer prayer while he needs to answer the call of nature until he relieves himself." This is related by Ahmad, Abu Dawud, and at-Tirmizhi who calls it hasan.

'Aishah reported that she heard the Messenger of Allah say: "No one should pray when the food is served nor when one needs to answer the call of nature." This is related by Ahmad, Muslim, and Abu Dawud.

Related Hadith(s)