9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Jacob Moody <moody@mail.posixcafe.org>
To: 9front@9front.org
Subject: Re: [9front] srv(3) clone and srvid
Date: Wed, 29 Mar 2023 14:31:16 -0600	[thread overview]
Message-ID: <21fea124-b5a9-db54-561d-f0dff24a084e@posixcafe.org> (raw)
In-Reply-To: <7DE8FD327C993A1A92A480A88E8B9D4E@smtp.pobox.com>

On 3/29/23 14:15, unobe@cpan.org wrote:
> Quoth ori@eigenstate.org:
>> Quoth Jacob Moody <moody@mail.posixcafe.org>:
>>> Yes, clone works like how it does in /net, the board is only open for as long
>>> as you have the fd open. So you cat'd it which opened it, read the new id, then closed
>>> it deallocating the child srv. You need to keep the fd open for the length of time you
>>> use the child srv, Or if you wish to 'pin' the child srv you can stash the clone fd itself
>>> as a file in the child srv. This will keep the child srv around until you remove the pinned
>>> clone fd.
> 
> Thank you Moody. I'm still misunderstanding something because I would have that:
> 	 bind -c '#s20' /srv
> when /srv/20 isn't available would have failed somehow, since the man page states:
>     As a convention, /lib/namespace
> 	accepts the path to the service directory from the environ-
> 	ment variable $srvspec, making it possible to start a new
> 	namespace using a specific service directory as a starting
> 	point.
> 
> But for comparison, this has no failure either:
> 	bind '#l20' /net
> so I still need to wrap my head around something.


#s20 and $s/20 are different things. The first is an attach argument,
the second is access the sub directory 20.

> 
>> for an example of how it's used on shithub:
>> 	
>> 	<[3]/srv/clone{
>> 		d=`{<[0=3]read}
>> 		bind /srv/$d /srv
>> 		# ugly, but we don't want to leak the clone fd into
>> 		# procs that may stick around, so write over fd3 again
>> 		<[3=0]{
>> 			rfork n
>> 			bind /usr/web /mnt/static
>> 			execfs -m /usr/web /sys/lib/tcp80/gitrules
>> 			bind /mnt/static /usr/web/static
>> 			rfork n
>> 			cd /
>> 			exec /bin/tcp80
>> 		}
>> 	}
>>
> 
> Thank you Ori, that was very helpful.  I was surprised to see that the
> file is left open when there's an rc error:
> 	cpu% lc /srv
> 	acme.glenn.3372	cons			hjfs.cmd		rio.glenn.504
> 	acme.glenn.908	cs				mntexport		rio.glenn.836
> 	boot			dns				pin-glenn		slashmnt
> 	clone			factotum		plumb.glenn.495	slashn
> 	cpu% </srv/clone { d=`{<f} }
> 	/fd/0:2: < can't open: f: 'f' not found
> 	cpu% lc /srv
> 	36/				cons			mntexport		slashmnt
> 	acme.glenn.3372	cs				pin-glenn		slashn
> 	acme.glenn.908	dns				plumb.glenn.495
> 	boot			factotum		rio.glenn.504
> 	clone			hjfs.cmd		rio.glenn.836
> 	cpu% bind -c '#s36' /srv
> 	cpu% lc /srv
> 	36/				cons			mntexport		slashmnt
> 	acme.glenn.3372	cs				pin-glenn		slashn
> 	acme.glenn.908	dns				plumb.glenn.495
> 	boot			factotum		rio.glenn.504
> 	clone			hjfs.cmd		rio.glenn.836
> 	cpu% bind -c '#s'/36 /srv
> 	cpu% lc /srv
> 	clone
> 
> When the window is closed, then 36/ finally is cleaned up.
> 
> 
This seems like an rc bug that is leaking the file descriptor.

      reply	other threads:[~2023-03-29 20:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 17:45 unobe
2023-03-29 17:51 ` Jacob Moody
2023-03-29 19:00   ` ori
2023-03-29 20:15     ` unobe
2023-03-29 20:31       ` Jacob Moody [this message]

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=21fea124-b5a9-db54-561d-f0dff24a084e@posixcafe.org \
    --to=moody@mail.posixcafe.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).