helpThe GNU Bourne-Again SHell - Support: sr #108732, named pipe leaks for systems not...


sr #108732: named pipe leaks for systems not support DEV_FD

Submitted by:  Kuang-che Wu <kcwu>
Submitted on:  Wed 21 Jan 2015 05:23:28 PM UTC  
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  *BSD

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 13 Nov 2015 03:51:42 PM UTC, comment #1: 

This was fixed back in April 2015, and the fix is in bash-4.4.

Chet Ramey <chet>
Project Administrator
Wed 21 Jan 2015 05:23:28 PM UTC, original submission:  

How to reproduce:
On FreeBSD 11 (or other OS without DEV_FD support)
bash version 4.3.30 -- IIRC, this problem exists more than 1 year.

$ bash -c 'cat <(echo yes)'

bash will create named pipe, say, /tmp/sh-np-NNNNN
Then fork a child to execute "echo yes" and output to /tmp/sh-np-NNNNN.
Then "exec" in the main shell "cat /tmp/sh-np-NNNNN".
The problem is, bash didn't fork. After exec, the named pipe /tmp/sh-np-NNNNN is never deleted.

I found following code in execute_cmd.c, inside execute_simple_command(), line 4223.

  if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0)
    simple_command->flags &= ~CMD_NO_FORK;

subshell_environment is 0 for my case.
If ignore first condition and remove CMD_NO_FORK in simple_command->flags, unlink_fifo_list() will be correctly invoked and the named pipe got deleted.

I don't fully understand what is subshell_environment and have no idea how to fix it properly, thus I don't provide patch.

Kuang-che Wu <kcwu>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by kcwu (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-13 chet StatusNone => Done

    Back to the top

    Powered by Savane 3.7