Signed-off-by: Harsh Prateek Bora <[email protected]>
---
 testcases/kernel/syscalls/setrlimit/setrlimit01.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit01.c 
b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
index 6952eb3..d8949c6 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit01.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
@@ -156,7 +156,12 @@ void test2()
         * an wired value!  So, it is essential to fflush the parent's
         * write buffer HERE
         */
+       int pipefd[2];
        fflush(stdout);
+       if (pipe(pipefd) == -1) {
+               perror("pipe");
+               exit(EXIT_FAILURE);
+       }
 
        /*
         * Spawn a child process, and reduce the filesize to
@@ -170,6 +175,7 @@ void test2()
        }
 
        if (pid == 0) {
+               close(pipefd[0]); /* close unused read end */
                rlim.rlim_cur = 10;
                rlim.rlim_max = 10;
                if ((setrlimit(RLIMIT_FSIZE, &rlim)) == -1) {
@@ -181,6 +187,8 @@ void test2()
                }
 
                if ((bytes = write(fd, buf, 26)) != 10) {
+                       write(pipefd[1], &bytes, sizeof(bytes));
+                       close(pipefd[1]); /* EOF */
                        exit(3);
                }
                exit(0);        /* success */
@@ -202,6 +210,9 @@ void test2()
                tst_resm(TFAIL, "creating testfile failed");
                break;
        case 3:
+               close(pipefd[1]); /* close unused write end */
+               read(pipefd[0], &bytes, sizeof(bytes));
+               close(pipefd[0]);
                tst_resm(TFAIL, "setrlimit failed, expected "
                         "10 got %d", bytes);
                break;
-- 
1.7.1.1


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to