Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“too many open files” error in awk #9

Open
lucaswerkmeister opened this issue Aug 14, 2018 · 0 comments · May be fixed by #10
Open

“too many open files” error in awk #9

lucaswerkmeister opened this issue Aug 14, 2018 · 0 comments · May be fixed by #10

Comments

@lucaswerkmeister
Copy link
Contributor

I am running pmonitor -i1 on a long-running cp process that copies some large files but also very many small files, and I’m getting this error:

awk: cmd. line:4: (FILENAME=- FNR=18787) fatal: cannot open pipe `date +%s' (Too many open files)

I think file_length is leaking file descriptors (though I’m not quite sure about the details).

PR incoming.

lucaswerkmeister added a commit to lucaswerkmeister/pmonitor that referenced this issue Aug 14, 2018
When an AWK program reads from a file or process, AWK keeps the
connection to the file or process open until the program explicitly
closes it. This is useful in order to read multiple lines from a file,
or to keep reading input from a long-running coprocess, but it also
means that we must make sure to close any short helper program we
launch, otherwise we will leak one file descriptor (the pipe to the
child process) per invocation and eventually run out of file descriptors
(EMFILE Too many open files). (See also the time() function for an
example where we already do this.)

Fixes dspinellis#9.
@lucaswerkmeister lucaswerkmeister linked a pull request Aug 14, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant