bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Procsub.tests on OSes using named pipes


From: CHIGOT, CLEMENT
Subject: Re: Procsub.tests on OSes using named pipes
Date: Thu, 20 Feb 2020 14:32:54 +0000

I've just figured that the [ -e "$1" ] in the handler might cause some 
problems. 
Sometimes, the named pipes isn't yet removed thus [ -e "$1" ] will be true and 
the return part won't be called. 
I'm not sure why it isn't removed directly, but it might just be how the AIX 
kernel is handling files. 
Therefore, here is the second version of the patch. 

Note that I'm still trying to find a fix for the unkilled subprocesses stuck in 
the open syscall. 
I might have found a workaround but not a true fix yet. Moreover, I still have 
some freezes sometimes. 
The workaround consists on forcing an open + unlink of all the FIFOs created by 
a bash when this one is closing.  
I'll keep you update. 

-----------------------------------------------------

[PATCH] tests: fix procsubs tests on OSes using named pipes

On OSes using named pipes (like AIX), the pipe's file is suppressed
after the first read. Thus every commands trying to read it afterwards
will fail with ENOENT errno.
---
 tests/procsub.tests | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/procsub.tests b/tests/procsub.tests
index 01ba46a8..22c0b29f 100644
--- a/tests/procsub.tests
+++ b/tests/procsub.tests
@@ -69,10 +69,12 @@ count_lines()
 {
     wc -l < $1

-#    case "$1" in
-#    *sh-np*)  [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
-#    *) ;;
-#    esac
+    # For OSes using named pipes, $1 will be deleted after the first read and
+    # thus ENOENT error will be returned for every following commands.
+    case "$1" in
+    *sh-np*)    echo 0; echo 0; echo 0; echo 0; return;;
+    *) ;;
+    esac

     wc -l < $1
     wc -l < $1
@@ -88,6 +90,10 @@ echo extern
 FN=$TMPDIR/bashtest-$$
 cat >$FN << \EOF
 wc -l < $1
+case "$1" in
+*sh-np*)    echo 0; echo 0; echo 0; echo 0; return;;
+*) ;;
+esac
 wc -l < $1
 wc -l < $1
 true | wc -l < $1
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]