'man dup2' says:
dup2() makes newfd be the copy of oldfd, closing newfd first if
necessary, but note the following:
* If oldfd is not a valid file descriptor, then the call fails,
and newfd is not closed.
* If oldfd is a valid file descriptor, and newfd has the same
value as oldfd, then dup2() does nothing, and returns newfd.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
mkdev("*console", 0600);
dd = open(dev, O_RDWR);
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
if (dd < 0) {
ERROR("Failed to open %s\n", dev);
return;