Race condition when using dup2
问题 This manpage for the dup2 system call says: EBUSY (Linux only) This may be returned by dup2() or dup3() during a race condition with open(2) and dup(). What race condition does it talk about and what should I do if dup2 gives EBUSY error? Should I retry like in the case of EINTR ? 回答1: There is an explanation in fs/file.c , do_dup2(): /* * We need to detect attempts to do dup2() over allocated but still * not finished descriptor. NB: OpenBSD avoids that at the price of * extra work in their