9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Backgrounding a task
@ 2017-10-24 14:21 Alex Musolino
  2017-10-24 19:18 ` Giacomo Tesio
  2017-10-24 23:00 ` Chris McGee
  0 siblings, 2 replies; 13+ messages in thread
From: Alex Musolino @ 2017-10-24 14:21 UTC (permalink / raw)
  To: 9fans

> The namespace join facility looks interesting. Do you have a patch
> somewhere for it?

I'll see what I can dig up though it wouldn't tbe erribly difficult to
reimplement.  You basically just need to modify the pgrp pointer of
the proc, adjusting ref counts as required.

>> Of course, a lot of the isolation that per-process namespaces give
>> you is suddenly undone by the introduction of this facility.
>
> I'm not sure if the lack of isolation is any different than what can
> be done with a child process that shares the namespace.  Is there a
> particular case that you are thinking?

Creating a child process is something that a process explicitly
controls and the RFNOTEG flag of rfork(2) allows a process to control
whether or not it shares its namespace with its children.  Allowing
other, unrelated processes to fiddle with your namespace is quite
different.

Think about multiple processes owned by multiple users running on a
cpu server.  Which processes should be allowed to join which
namespaces?

Perhaps allowing only the hostowner to join namespaces for debugging
and administration purposes would be acceptable.

>> At this point I'm not entirely convinced that it's worth the
>> trouble.
> 
> I think that it can be depending on how much time you have spent
> building up a namespace for a process.  Perhaps I have spent hours
> working on something slowly customizing the namespace mounting and
> binding things.  If I end up running a long running command that
> blocks and I want to work in parallel with it then I must remember
> everything that I have done and repeat in a new window.  It seems
> like something the computer should do for me or at least help me to do
> it.

This seems a contrived example.  Would you really spend HOURS working
on setting up a namespace by hand?  Surely you would instead be
working on a script that builds the namespace for you; make the
computer do the work.  Then when you mess up, you can modify the
script, create a new window, and try again.

One more thing to consider is the #σ device in 9front which seems to
address some of the problems that you might otherwise use nsjoin to
solve.

--
Cheers,
Alex Musolino




^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [9fans] Backgrounding a task
@ 2017-10-24  3:54 Alex Musolino
  2017-10-24 11:19 ` Chris McGee
  0 siblings, 1 reply; 13+ messages in thread
From: Alex Musolino @ 2017-10-24  3:54 UTC (permalink / raw)
  To: 9fans

> So far, it looks like the closest equivalent is to draw a new window
> and inherit the namespace of the original one by reading the namespace
> from the proc.

The problem with /proc/$pid/ns is entries that can't be "replayed".
For example, the following command will not work:

	mount -b '#|/data' /mnt

Nor does it provide any real indication as to what exactly is hooked
up to the other end of the 9P pipe.

> I wonder if there could be a Rio gesture to draw a new window
> inheriting the namespace of the window I pick by clicking.

Rio can't access the namespaces of the processes running in its
windows.  The -m option to window(1) works by rforking a new process
with the RFNAMEG flag set and then doing the appropriate mounting and
binding to create and use a new rio window.

Some months ago I played with the idea of adding support for an
"nsjoin" command to the /proc/$pid/ctl file.  This allowed you to join
the namespace of another process a little something like this:

	term% ps | grep plumber
	alex            670    0:00   0:00      864K Pread    plumber
	alex            671    0:00   0:00      864K Rendez   plumber
	term% echo nsjoin 670 >/proc/$pid/ctl
	term%

Subsequent changes to the namespace would affect the plumber.  If you
wanted a copy, just do 'rfork n' after joining the namespace.

Of course, a lot of the isolation that per-process namespaces give you
is suddenly undone by the introduction of this facility.  At this
point I'm not entirely convinced that it's worth the trouble.

--
Cheers,
Alex Musolino




^ permalink raw reply	[flat|nested] 13+ messages in thread
* [9fans] Backgrounding a task
@ 2017-10-06 23:33 Chris McGee
  2017-10-07  1:42 ` Erik Quanstrom
  2017-10-07  4:04 ` Skip Tavakkolian
  0 siblings, 2 replies; 13+ messages in thread
From: Chris McGee @ 2017-10-06 23:33 UTC (permalink / raw)
  To: 9fans

Hi All,

When I'm using Unix, there's a workflow that I use for long running commands that I'm hoping to find the equivalent in the Plan 9 way of doing things.

I will occasionally run a command, realize that it will take a long time to complete. I don't want to kill it. I'll just Ctrl-Z and bg to put it into the background using the shell. It's almost as if I had run it with '&' in the first place. I can then run other commands in the same working directory, environment and shell history.

Is there an equivalent to this workflow in Plan 9?

I realize that the whole job control system dates back to old single session terminals, which isn't a problem with Rio where you can draw new windows at will. Initially I thought, that you just drag that window to a corner somewhere and let it complete. But, if I draw a new window it won't be in the same working directory, have the same environment and namespace. Maybe there is a way to create a window that inherits these from an existing process?

Chris


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

end of thread, other threads:[~2017-10-24 23:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 14:21 [9fans] Backgrounding a task Alex Musolino
2017-10-24 19:18 ` Giacomo Tesio
2017-10-24 22:07   ` Giacomo Tesio
2017-10-24 23:00 ` Chris McGee
2017-10-24 23:13   ` Giacomo Tesio
  -- strict thread matches above, loose matches on Subject: below --
2017-10-24  3:54 Alex Musolino
2017-10-24 11:19 ` Chris McGee
2017-10-06 23:33 Chris McGee
2017-10-07  1:42 ` Erik Quanstrom
2017-10-07  4:04 ` Skip Tavakkolian
2017-10-07 12:21   ` Chris McGee
2017-10-23 17:20     ` Yaroslav Kolomiiets
2017-10-24  1:48       ` Chris McGee

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