[lxc-devel] [PATCH 2/6] af_unix: make sure to keep useful errno

Stéphane Graber stgraber at ubuntu.com
Mon Mar 4 22:01:35 UTC 2013


On 03/04/2013 03:43 PM, Serge Hallyn wrote:
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/af_unix.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c
> index 2a34828..f6c65fb 100644
> --- a/src/lxc/af_unix.c
> +++ b/src/lxc/af_unix.c
> @@ -56,12 +56,16 @@ int lxc_af_unix_open(const char *path, int type, int flags)
>  	       path[0]?strlen(path):sizeof(addr.sun_path));
>  
>  	if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
> +		int tmp = errno;
>  		close(fd);
> +		errno = tmp;
>  		return -1;
>  	}
>  	
>  	if (type == SOCK_STREAM && listen(fd, 100)) {
> +		int tmp = errno;
>  		close(fd);
> +		errno = tmp;
>  		return -1;
>  	}
>  
> @@ -99,7 +103,9 @@ int lxc_af_unix_connect(const char *path)
>  	       path[0]?strlen(path):sizeof(addr.sun_path));
>  
>  	if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
> +		int tmp = errno;
>  		close(fd);
> +		errno = tmp;
>  		return -1;
>  	}
>  
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130304/dd1fb628/attachment.pgp>


More information about the lxc-devel mailing list