Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/bin/dd
> > What is wrong with:
> > new_fd = fcntl(fd, F_DUPFD, 3);
> > close(fd);
> > fd = newfd;
>
> I did consider that, but it seems more error-prone.
>
> E.g. "dd if=foo of=/dev/fd/3" would break.
>
> Also, the fcntl(F_DUPFD)/dup2() would implicitly close the file
> descriptor on 3. Not usually a problem, but certainly new behaviour.
> Who knows, someone somewhere might use closure of fd 3 as an awful way
> to determine if "dd" has exited or not :)
fcntl(F_DUPFD) gives you the next free fd number great than or equal to
to the one given - unlike dup2() which gives a fixed number and might close
whathever was there before.
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index