tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.8k stars 182 forks source link

Pipeline of 3 or more commands leaks Unix sockets #438

Open ezamriy opened 5 years ago

ezamriy commented 5 years ago

I've noticed that a pipeline of 3 or more commands leaks Unix sockets until a process is crashed with "Too many open files" error.

Steps to reproduce:

  1. Run the following code:
    import plumbum
    cat = plumbum.local['cat']
    grep = plumbum.local['grep']
    while True:
        print (cat['/etc/passwd'] | grep['root'] | cat)()
  2. See the number of opened descriptors increasing:
    ls -la /proc/${PID}/fd | wc -l
  3. After some time (dependent on system limits) the process will crash.

Both 1.6.6 and 1.6.7 versions are affected.

The issue is not reproducible with 2-command pipelines.

ChrisGute commented 5 years ago

+1 same here

deniswvieira commented 4 years ago

+1. plumbum==1.6.8

A workaround can be: local['bash']['-c', 'cat /etc/passwd | grep "root" | cat']()