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

 
 

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

Submitter:  Kuang-che Wu <kcwu>
Submitted:  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
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 defined (PROCESS_SUBSTITUTION)
  if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0)
    simple_command->flags &= ~CMD_NO_FORK;
#endif

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:
   
   
Comment:
   

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    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.13-f8d8.
    Corresponding source code