sandbox: eth-raw: do not close the console input

When the sandbox eth-raw device host_lo is removed this leads to closing
the console input.

Do not call close(0).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Heinrich Schuchardt 2020-10-27 20:29:21 +01:00 committed by Simon Glass
parent 35b7ca768f
commit 6eec4b04a2
2 changed files with 8 additions and 5 deletions

View file

@ -53,7 +53,7 @@ int sandbox_eth_raw_os_is_local(const char *ifname)
} }
ret = !!(ifr.ifr_flags & IFF_LOOPBACK); ret = !!(ifr.ifr_flags & IFF_LOOPBACK);
out: out:
close(fd); os_close(fd);
return ret; return ret;
} }
@ -220,7 +220,7 @@ int sandbox_eth_raw_os_send(void *packet, int length,
struct sockaddr_in addr; struct sockaddr_in addr;
if (priv->local_bind_sd != -1) if (priv->local_bind_sd != -1)
close(priv->local_bind_sd); os_close(priv->local_bind_sd);
/* A normal UDP socket is required to bind */ /* A normal UDP socket is required to bind */
priv->local_bind_sd = socket(AF_INET, SOCK_DGRAM, 0); priv->local_bind_sd = socket(AF_INET, SOCK_DGRAM, 0);
@ -284,11 +284,11 @@ void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
{ {
free(priv->device); free(priv->device);
priv->device = NULL; priv->device = NULL;
close(priv->sd); os_close(priv->sd);
priv->sd = -1; priv->sd = -1;
if (priv->local) { if (priv->local) {
if (priv->local_bind_sd != -1) if (priv->local_bind_sd != -1)
close(priv->local_bind_sd); os_close(priv->local_bind_sd);
priv->local_bind_sd = -1; priv->local_bind_sd = -1;
priv->local_bind_udp_port = 0; priv->local_bind_udp_port = 0;
} }

View file

@ -86,7 +86,10 @@ int os_open(const char *pathname, int os_flags)
int os_close(int fd) int os_close(int fd)
{ {
/* Do not close the console input */
if (fd)
return close(fd); return close(fd);
return -1;
} }
int os_unlink(const char *pathname) int os_unlink(const char *pathname)