[lxc-devel] [PATCH] tests: try again when waitpid() sets errno as EINTR

Arjun Sreedharan arjun024 at gmail.com
Thu Dec 4 08:56:04 UTC 2014


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 <arjun024 at gmail.com>
---
 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



More information about the lxc-devel mailing list