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

Ruslan Kuprieiev kupruser at gmail.com
Tue Dec 2 01:36:08 PST 2014


On 12/02/2014 10:42 AM, Pavel Emelyanov wrote:
> On 12/02/2014 01:52 AM, 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
>
> That's a nice question to thing about -- is it normal to use
> glibc error codes for higher level errors? Thoughts?
>

We already use them in 
libcriu(https://github.com/xemul/criu/blob/master/lib/criu.h#L70). And 
using them at RPC now will
allow us to set rpc err in 
libcriu(https://github.com/xemul/criu/blob/master/lib/criu.h#L79), just 
the way we planned.

>> + */
>> +
>>   #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;
>>   		return -1;
>>   	}
>>
>>
>



More information about the CRIU mailing list