9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Romano <unobe@cpan.org>
To: 9front@9front.org
Subject: [9front] rc: asynchronous read fds do not close/free
Date: Wed, 18 Oct 2023 20:33:10 -0700	[thread overview]
Message-ID: <008168B6FF1F96B534709558629B6497@smtp.pobox.com> (raw)

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?


                 reply	other threads:[~2023-10-19  3:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=008168B6FF1F96B534709558629B6497@smtp.pobox.com \
    --to=unobe@cpan.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).