[CRIU] [PATCH 2/9] util: set cr_errno to ESRCH if no PID dir in proc

Pavel Emelyanov xemul at parallels.com
Wed Dec 10 02:25:21 PST 2014


On 12/03/2014 10:13 PM, Ruslan Kuprieiev wrote:
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  include/cr-errno.h | 5 +++++
>  util.c             | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/include/cr-errno.h b/include/cr-errno.h
> index 6ca6c68..bec72a8 100644
> --- a/include/cr-errno.h
> +++ b/include/cr-errno.h
> @@ -1,4 +1,9 @@
>  #ifndef __CR_ERRNO_H__
>  #define __CR_ERRNO_H__
>  extern int cr_errno;
> +/*
> + * List of symbolic error names:
> + * ESRCH	- no process can be found corresponding to that specified by pid
> + */
> +
>  #endif /* __CR_ERRNO_H__ */
> diff --git a/util.c b/util.c
> index dd76863..7b38351 100644
> --- a/util.c
> +++ b/util.c
> @@ -42,6 +42,8 @@
>  #include "servicefd.h"
>  #include "cr-service.h"
>  
> +#include "cr-errno.h"
> +
>  #define VMA_OPT_LEN	128
>  
>  static void vma_opt_str(const struct vma_area *v, char *opt)
> @@ -268,6 +270,7 @@ inline int open_pid_proc(pid_t pid)
>  	fd = openat(dfd, path, O_RDONLY);
>  	if (fd < 0) {
>  		pr_perror("Can't open %s", path);
> +		cr_errno = ESRCH;

I wouldn't access the cr_errno directly. For example, after this error
there can be called some other function that would overwrite one. Thus
a helper, that would remember only the first one would be nice.

The same is true for the atomic errno set on restore -- helper function
would help.

>  		return -1;
>  	}
>  
> 



More information about the CRIU mailing list