rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* File descriptor leak.
@ 1991-11-10  3:38 David J. Fiander
  0 siblings, 0 replies; 2+ messages in thread
From: David J. Fiander @ 1991-11-10  3:38 UTC (permalink / raw)
  To: rc

rc slowly opens, and then forgets about file descriptors when
one uses the "<{cmd}" construct on a system with /dev/fd.  The
problem is that glom() calls mkcmdarg(), which creates a pipe,
forks, sets up the child to read from (or write to) the pipe,
sets the name of the argument for the parent, and then forgets
about the file.  After the pipeline has terminated (or rc has
forked to execute the pipeline), then rc should close the pipe
end it has open, but it never does.  The best way to see this
behaviour, is to repeatedly run the command

	echo <{echo hello world}

This will create the pipe between the inner echo and the out
echo, but the outer echo will simply echo the name of the file
which was passed to it.  If the problem did not exist, then the
same file name would be echoed every time, but it isn't.
Eventually, you will run out of fds.

Anybody got any ideas?

--
David J. Fiander   |A man ought to read just as inclination leads him; for
<david@golem.uucp> |what he reads as a task will do him little good.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: File descriptor leak.
@ 1991-11-10  3:50 David J. Fiander
  0 siblings, 0 replies; 2+ messages in thread
From: David J. Fiander @ 1991-11-10  3:50 UTC (permalink / raw)
  To: rc


>From:  "David J. Fiander" <david>
>rc slowly opens, and then forgets about file descriptors when
>one uses the "<{cmd}" construct on a system with /dev/fd.  The
>problem is that glom() calls mkcmdarg(), which creates a pipe,
>forks, sets up the child to read from (or write to) the pipe,
>sets the name of the argument for the parent, and then forgets
>about the file.  After the pipeline has terminated (or rc has

More info:  when using named pipes to do all this, rc maintains
a list of fifo file names which it unlinks after the pipeline
has completed.  The code to build the list is all conditionally
compiled in, but the code to clean up is always there
(fortunately, it sees that there is no list of fifos, and just
returns).  The problem can be fixed by adding code to
mkcmdarg() to maintain the fifoq, so that when the pipeline
terminates, empty_fifoq() will _close_ all the pipes that were
created.

How does that sound?

--
David J. Fiander   |A man ought to read just as inclination leads him; for
<david@golem.uucp> |what he reads as a task will do him little good.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1991-11-10  4:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-11-10  3:38 File descriptor leak David J. Fiander
1991-11-10  3:50 David J. Fiander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).