And that which we say in the Gemara there, that when there were two and the time for the recitation of Shema arrived, one ascends and recites Shema and prays, and then this one returns and digs and his fellow ascends and recites Shema and prays—truthfully, the Tur and the Shulchan Aruch wrote in the name of the Ramban that this is only in a niche where two cannot dig it together. But in a grave where two dig it together—neither of them shall stop, see there. And so they wrote later in siman 403 (Shulchan Aruch Yoreh Deah 403) regarding the gathering of bones, that even if there were many gathering—they shall not stop for any mitzvah. And it is all for the reason that we explained. And it seems to me that it is not specifically regarding the digging of a grave, but rather the same law applies to all the needs of the deceased when one is occupied, if he is compelled to occupy himself with this, such as when the onen is unable to do this thing, or if there are no mourners here—the one occupied is exempt from all mitzvot. However, it seems to me that all this is when he is occupied for free for the sake of a mitzvah. But when he comes for his wage, such as the gravediggers who take payment for their exertion—they are not called "those occupied with a mitzvah" such that they would be exempt from another mitzvah, for they are not occupied for the sake of the mitzvah. However, if it is impossible without them, in that only they are able to occupy themselves with this and not another—they should not nullify their work because of another mitzvah, because of the honor of the deceased.
והא דאמרינן בגמרא שם דכשהיו שנים והגיע זמן קריאת שמע אחד עולה וקורא קריאת שמע ומתפלל, וחוזר זה וחופר ועולה חבירו וקורא קריאת שמע ומתפלל – באמת כתבו הטור והשולחן ערוך בשם הרמב"ן דזהו רק בכוך שאין שנים חופרין אותו ביחד. אבל בקבר ששנים ביחד חופרין אותו – לא יפסוק אף אחד מהם, עיין שם. וכן כתבו לקמן בסימן ת"ג (שולחן ערוך יורה דעה תג) גבי ליקוט עצמות, דאפילו היו רבים המלקטים – לא יפסיקו לשום מצוה. והכל הוא מטעם שבארנו. ונראה לי דלאו דווקא בחפירת קבר, אלא הוא הדין בכל צרכי המת כשעוסק אם הוא מוכרח לעסוק בזה, כגון שהאונן אין ביכולתו לעשות דבר זה, או שאין כאן אבלים – פטור העוסק מכל המצות. ומיהו נראה לי דכל זה הוא כשעוסק בחינם לשם מצוה. אבל כשבא בשכרו, כגון הקברנים שנוטלים שכירות בעד טרחתם – לא נקראו עוסקי במצוה שיהיו פטורים ממצוה אחרת, שהרי לא לשם מצוה הם עוסקים. ומיהו אם אי אפשר בלעדם, דרק המה ביכולתם לעסוק בזה ולא אחר – אין להם לבטל עשייתם מפני מצוה אחרת, מפני כבודו של מת.