int
direct_safe_dup( int fd )
{
int n = 0;
int fc[3];
while (fd >= 0 && fd <= 2) {
fc[n++] = fd;
fd = dup (fd);
}
while (n)
close (fc[--n]);
return fd;
}
代码来源directfb
direct_safe_dup( int fd )
{
int n = 0;
int fc[3];
while (fd >= 0 && fd <= 2) {
fc[n++] = fd;
fd = dup (fd);
}
while (n)
close (fc[--n]);
return fd;
}