كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(7)
Chapter: The prohibition of speaking during the prayer, and the abrogation of its former permissibility
(7)
باب تَحْرِيمِ الْكَلاَمِ فِي الصَّلاَةِ وَنَسْخِ مَا كَانَ مِنْ إِبَاحَتِهِ ‏
Sahih Muslim 538 a

Abdullah (b. Masu'd) reported:

We used to greet the Messenger of Allah (ﷺ) while he was engaged in prayer and he would respond to our greeting. But when we returned from the Negus we greeted him and he did not respond to us; so we said: Messenger of Allah. we used to greet you when you were engaged in prayer and you would respond to us. He replied: Prayer demands whole attention.
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَزُهَيْرُ بْنُ حَرْبٍ، وَابْنُ، نُمَيْرٍ وَأَبُو سَعِيدٍ الأَشَجُّ - وَأَلْفَاظُهُمْ مُتَقَارِبَةٌ - قَالُوا حَدَّثَنَا ابْنُ فُضَيْلٍ، حَدَّثَنَا الأَعْمَشُ، عَنْ إِبْرَاهِيمَ، عَنْ عَلْقَمَةَ، عَنْ عَبْدِ اللَّهِ، قَالَ كُنَّا نُسَلِّمُ عَلَى رَسُولِ اللَّهِ صلى الله عليه وسلم وَهُوَ فِي الصَّلاَةِ فَيَرُدُّ عَلَيْنَا فَلَمَّا رَجَعْنَا مِنْ عِنْدِ النَّجَاشِي سَلَّمْنَا عَلَيْهِ فَلَمْ يَرُدَّ عَلَيْنَا فَقُلْنَا يَا رَسُولَ اللَّهِ كُنَّا نُسَلِّمُ عَلَيْكَ فِي الصَّلاَةِ فَتَرُدُّ عَلَيْنَا ‏.‏ فَقَالَ ‏ "‏ إِنَّ فِي الصَّلاَةِ شُغُلاً ‏"‏ ‏.‏
Reference : Sahih Muslim 538a
In-book reference : Book 5, Hadith 41
USC-MSA web (English) reference : Book 4, Hadith 1096
  (deprecated numbering scheme)