9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] rc: asynchronous read fds do not close/free
@ 2023-10-19  3:33 Romano
  0 siblings, 0 replies; only message in thread
From: Romano @ 2023-10-19  3:33 UTC (permalink / raw)
  To: 9front

All,

When creating a small helper script, I noticed that the fd for
asynchronous reads were not being closed or freed.  I'm not sure the
proper terminology, so here's an example:

cpu% echo 'while() {
	sleep 1
	cat <{echo -n}
	wc -l /proc/$pid/fd
	}' | rc
      6 /proc/858741/fd
      7 /proc/858741/fd
      8 /proc/858741/fd
      9 /proc/858741/fd
     10 /proc/858741/fd
     …
rc 858741: warning: process exceeds 100 file descriptors

I think the warning is from /sys/src/9/port/sysfile.c:21 . If I
replace the asynchronous read with a simple input redirect, the fds
are closed (i.e., replace <{echo -n} with </dev/null):

cpu% echo 'while() {
	sleep 1
	cat </dev/null
	wc -l /proc/$pid/fd
	}' | rc
      5 /proc/864328/fd
      5 /proc/864328/fd
      5 /proc/864328/fd
      5 /proc/864328/fd
      5 /proc/864328/fd
      …

After 100 or so seconds, I don't get the same warning as with the other script.

I don't see this behavior described in rc(1), or listed as a BUG, but
is this behavior correct?  Does anyone have an idea of why the fds are
increasing, and if so, is there a way to keep it from happening?


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-19  3:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19  3:33 [9front] rc: asynchronous read fds do not close/free Romano

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