Red Hat Bugzilla – Bug 89560
pipe-open() leaks filedescriptor when program fails to execute
Last modified: 2007-11-30 17:06:52 EST
Description of problem:
When using open() to read the output of a program and the execution of the
program fails, perl is leaking a filedescriptor.
E.g. look at fd 3 in:
| $ strace perl -e 'open(FH, "/NOT-THERE |"); close FH; waitpid -1,0;'
| pipe([3, 4]) = 0
| pipe([5, 6]) = 0
| fork() = 22128
| close(4) = 0
| close(6) = 0
| read(5, "\2\0\0\0", 4) = 4
| close(5) = 0
| wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 1], 0, NULL) = 22128
| --- SIGCHLD (Child exited) ---
| rt_sigprocmask(SIG_SETMASK, , NULL, 8) = 0
| _exit(0) = ?
fd 3 will be created by the pipe() syscall but never be closed.
perl-5.8 is closing it automatically and perl-5.0 returns the filedescriptor in
'FH'. But with the shipped perl-5.6.1 there does not exist a way to close it.
IMO this is a very critical bug; it brought down some of my servers running a
perl-based monitoring software.
Version-Release number of selected component (if applicable):
Created attachment 91376 [details]
Fixes filedescriptor leak
This patch contains backported code from 5.8.0 and fixes the
filedescriptor-leak. As a side-effect, a zombie-process will be prevented also.
fixed with perl-5.6.1-38.EL2_1
assigning to email@example.com