On Thu, Dec 4, 2014 at 11:47 AM, Stéphane Graber <stgra...@ubuntu.com> wrote:
> On Thu, Dec 04, 2014 at 02:26:04PM +0530, Arjun Sreedharan wrote:
>> when waitpid() is interrupted, errno is not set to the negative
>> value -EINTR. It is set to EINTR. check against EINTR.
>>
>> Signed-off-by: Arjun Sreedharan <arjun...@gmail.com>
>
> Acked-by: Stéphane Graber <stgra...@ubuntu.com>

hmm nice catch, I believe we need following too as rmdir and
lxc_unpriv returns non-negative error codes as well.

diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
index 9ccd666..9d0a735 100644
--- a/src/lxc/bdev.c
+++ b/src/lxc/bdev.c
@@ -1418,7 +1418,7 @@ static int btrfs_snapshot(const char *orig,
const char *new)
                goto out;
        }
        // make sure the directory doesn't already exist
-       if (rmdir(newfull) < 0 && errno != -ENOENT) {
+       if (rmdir(newfull) < 0 && errno != ENOENT) {
                SYSERROR("Error removing empty new rootfs");
                goto out;
        }
@@ -1511,7 +1511,7 @@ static int btrfs_clonepaths(struct bdev *orig,
struct bdev *new, const char *old
                return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata);
        }

-       if (rmdir(new->dest) < 0 && errno != -ENOENT) {
+       if (rmdir(new->dest) < 0 && errno != ENOENT) {
                SYSERROR("removing %s", new->dest);
                return -1;
        }
diff --git a/src/lxc/log.c b/src/lxc/log.c
index cb48600..13bd0e8 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -159,7 +159,7 @@ static int build_dir(const char *name)
                *p = '\0';
                if (access(n, F_OK)) {
                        ret = lxc_unpriv(mkdir(n, 0755));
-                       if (ret && errno != -EEXIST) {
+                       if (ret && errno != EEXIST) {
                                SYSERROR("failed to create directory '%s'.", n);
                                free(n);
                                return -1;

>> ---
>>  src/tests/containertests.c |    4 ++--
>>  src/tests/destroytest.c    |    2 +-
>>  src/tests/saveconfig.c     |    2 +-
>>  src/tests/startone.c       |    4 ++--
>>  4 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/tests/containertests.c b/src/tests/containertests.c
>> index 9230853..d093a02 100644
>> --- a/src/tests/containertests.c
>> +++ b/src/tests/containertests.c
>> @@ -48,7 +48,7 @@ static int destroy_busybox(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> @@ -80,7 +80,7 @@ static int create_busybox(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> diff --git a/src/tests/destroytest.c b/src/tests/destroytest.c
>> index 4bb6aae..eaf3c84 100644
>> --- a/src/tests/destroytest.c
>> +++ b/src/tests/destroytest.c
>> @@ -46,7 +46,7 @@ static int create_container(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> diff --git a/src/tests/saveconfig.c b/src/tests/saveconfig.c
>> index de2fa82..d8a4ca2 100644
>> --- a/src/tests/saveconfig.c
>> +++ b/src/tests/saveconfig.c
>> @@ -46,7 +46,7 @@ static int create_container(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> diff --git a/src/tests/startone.c b/src/tests/startone.c
>> index 9dd4ec3..6b7344f 100644
>> --- a/src/tests/startone.c
>> +++ b/src/tests/startone.c
>> @@ -48,7 +48,7 @@ static int destroy_container(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> @@ -80,7 +80,7 @@ static int create_container(void)
>>  again:
>>       ret = waitpid(pid, &status, 0);
>>       if (ret == -1) {
>> -             if (errno == -EINTR)
>> +             if (errno == EINTR)
>>                       goto again;
>>               perror("waitpid");
>>               return -1;
>> --
>> 1.7.10.1
>>
>
> --
> Stéphane Graber
> Ubuntu developer
> http://www.ubuntu.com
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel@lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
>



-- 
S.Çağlar Onur <cag...@10ur.org>
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to