@@ -804,6 +804,32 @@ INTERPOSE(int, fclose, FILE *f) ({
804804 return bxl->fwd_fclose (f).restore ();
805805})
806806
807+ INTERPOSE(int , dup, int fd) ({
808+ return ret_fd (bxl->real_dup (fd), bxl);
809+ // Sometimes useful (for debugging) to interpose without access checking:
810+ // return bxl->fwd_dup(fd).restore();
811+ })
812+
813+ INTERPOSE(int , dup2, int oldfd, int newfd)({
814+ // If the file descriptor newfd was previously open, it is closed
815+ // before being reused; the close is performed silently, so we should reset the fd table.
816+ bxl->reset_fd_table_entry (newfd);
817+
818+ return bxl->real_dup2 (oldfd, newfd);
819+ // Sometimes useful (for debugging) to interpose without access checking:
820+ // return bxl->fwd_dup2(oldfd, newfd).restore();
821+ })
822+
823+ INTERPOSE(int , dup3, int oldfd, int newfd, int flags)({
824+ // If the file descriptor newfd was previously open, it is closed
825+ // before being reused; the close is performed silently, so we should reset the fd table.
826+ bxl->reset_fd_table_entry (newfd);
827+
828+ return bxl->real_dup3 (oldfd, newfd, flags);
829+ // Sometimes useful (for debugging) to interpose without access checking:
830+ // return bxl->fwd_dup3(oldfd, newfd).restore();
831+ })
832+
807833static void report_exit(int exitCode, void *args)
808834{
809835 BxlObserver::GetInstance ()->report_access (" on_exit" , ES_EVENT_TYPE_NOTIFY_EXIT, std::string (" " ), std::string (" " ));
@@ -828,13 +854,6 @@ int main(int argc, char **argv)
828854 printf (" Path: %s\n " , inst->GetReportsPath ());
829855}
830856
831- /* ============ Sometimes useful (for debugging) to interpose without access checking
832-
833- INTERPOSE(int, dup, int fd) ({ return bxl->fwd_dup(fd).restore(); })
834- INTERPOSE(int, dup2, int oldfd, int newfd)({ return bxl->fwd_dup2(oldfd, newfd).restore(); })
835-
836- =================================================================== */
837-
838857/* ============ don't need to be interposed =======================
839858
840859INTERPOSE(int, statfs, const char *pathname, struct statfs *buf)({
0 commit comments