bug-bash
[Top][All Lists]
Advanced

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

RE: named pipe leaked


From: No Name
Subject: RE: named pipe leaked
Date: Wed, 17 Nov 2010 16:43:38 -0800

(sorry for the previous garbled message, hopefully this one comes out 
better)Configuration Information [Automatically generated, do not 
change]:Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux jpadesk2.mtv.corp.google.com 2.6.32-gg252-generic 
#gg252-Ubuntu SMP Mon Sep 13 22:09:00 UTC 2010 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:
 Named pipes are being leaked.
 The named pipe created for the "echo stuff" in
  while read x; do echo $x ; done < <(echo stuff)
 is never closed.


Repeat-By:

Running the following script.

<test_named_pipe_leak.bash4.sh>
#!/bin/bash

func1() {
  local arr
  while read arr; do
    # The following cmd | cmd causes the leaked named pipe to be cleaned up.
    [ "$do_workaround" == yes ] && exec | exec
    # Normally code here would modify some env var. So can't use
    # "cmd | while read...".
  done< <(echo hello)
  echo func1_lsof=$(lsof | grep -c test_name.*pipe)
}

main() {
  local do_workaround=$1
  local tmpworkdir=/tmp/test_named_pipe_leak.tmp.$$
  mkdir -p $tmpworkdir

  lsof -p $$ > $tmpworkdir/lsof_start
  for ((i=0; i < 10; i++)); do
    func1
  done
  lsof -p $$ > $tmpworkdir/lsof_end
  diff -us $tmpworkdir/lsof_start $tmpworkdir/lsof_end

  rm -rf $tmpworkdir

}

main "$@"
</test_named_pipe_leak.bash4.sh>

Running
  ~/tmp/test_named_pipe_leak.bash4.sh  no
outputs
<output_txt>
func1_lsof=4
func1_lsof=5
func1_lsof=6
func1_lsof=7
func1_lsof=8
func1_lsof=9
func1_lsof=10
func1_lsof=11
func1_lsof=12
func1_lsof=13
--- /home/jpa/tmp/testdir.26477/lsof_start      2010-11-17 13:12:07.904919000 
-0800
+++ /home/jpa/tmp/testdir.26477/lsof_end        2010-11-17 13:12:11.280668000 
-0800
@@ -22,4 +22,14 @@
 test_name 26477  jpa    0u   CHR  136,0      0t0        3 /dev/pts/0
 test_name 26477  jpa    1u   CHR  136,0      0t0        3 /dev/pts/0
 test_name 26477  jpa    2u   CHR  136,0      0t0        3 /dev/pts/0
+test_name 26477  jpa   54r  FIFO    0,8      0t0  5655855 pipe
+test_name 26477  jpa   55r  FIFO    0,8      0t0  5655740 pipe
+test_name 26477  jpa   56r  FIFO    0,8      0t0  5655627 pipe
+test_name 26477  jpa   57r  FIFO    0,8      0t0  5655514 pipe
+test_name 26477  jpa   58r  FIFO    0,8      0t0  5655401 pipe
+test_name 26477  jpa   59r  FIFO    0,8      0t0  5655288 pipe
+test_name 26477  jpa   60r  FIFO    0,8      0t0  5655175 pipe
+test_name 26477  jpa   61r  FIFO    0,8      0t0  5655051 pipe
+test_name 26477  jpa   62r  FIFO    0,8      0t0  5654938 pipe
+test_name 26477  jpa   63r  FIFO    0,8      0t0  5654823 pipe
 test_name 26477  jpa  255r   REG   0,27      712  6002620 
/home/jpa/tmp/test_named_pipe_leak.bash4.sh (mtvhome30.nfs:/vol/mtvhome30/jpa)
</output_txt>


Running
  ~/tmp/test_named_pipe_leak.bash4.sh  yes
outputs
<output_txt>
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
func1_lsof=3
Files /home/jpa/tmp/testdir.26915/lsof_start and 
/home/jpa/tmp/testdir.26915/lsof_end are identical
</output_txt>

                                          

reply via email to

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