You are not logged in.

#1 2010-07-04 17:55:34

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Why Are Multiple Shell Instances Necessary?

I usually run 10--12 terminals at any given time, and this doesn't take up to much memory since I can use the rxvt-unicode daemon urxvtd.
Yet each terminal has its own instance of bash, and this does take up memory.

What I wonder is whether it is really necessary for each terminal to have its own shell instance.
Obviously this is a necessity for independent history, but I really don't care too much about that.
Is there a way to run a bashd and have the individual shells hook into it? Is it even possible, or is there some consideration I have failed to make?

Maybe my workflow is flawed, I don't know.
My OCD nature prevents me from opening and closing terminals as whim, as there is a predetermined place for everything to go.
I always have the same terminals for their same respective things open on each workspace.
Some of them really don't need a complete shell though... for instance I have one to update svn and read commit logs, one for irc, and another for file transfer on my net workspace.
None of these need bash's features... I know I don't need bash underneath irssi but I do need some sort of command prompt to run my svn scripts and transfer programs.
In fact it seems most of my shells are more like command launchers, though I do want to see the output and be able to scroll back. Perhaps another shell would be better for me.
Only in a couple of my terminals do I actually use globbing and piping and such --- this is where bash is a necessity.
Of course if there was a way to hook the shells into one instance, I wouldn't feel so guilty about having so many open for so little purpose.

Also, I still don't know how to use a single terminal multiplexer, so obviously I will look into screen or tmux.

Any recommendations or insight would be greatly appreciated.

EDIT: I now know that it isn't possible to have a shell daemon, and I realize that my concern over memory usage is considered unfounded. Now I would like to know why no such program is available / why it's impossible. This is for my education.

Last edited by egan (2010-07-05 16:48:01)

Offline

#2 2010-07-04 18:43:11

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Why Are Multiple Shell Instances Necessary?

Short story: yes, multiple shell instances is needed.

And they really do take next to no resources so don't bother with it.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2010-07-04 18:44:43

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Why Are Multiple Shell Instances Necessary?

$ ps -Ao rss,vsize,cmd | grep bash | awk '{rss+=$1;virt+=$2}END{print "COUNT: " NR; print "RESIDENT: " int(rss/1024) " MB"; print "VIRTUAL: " int(virt/1024) " MB"}'
COUNT: 29
RESIDENT: 123 MB
VIRTUAL: 279 MB

I think this is acceptable.

Offline

#4 2010-07-04 19:05:28

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Why Are Multiple Shell Instances Necessary?

$ ps -Ao rss,vsize,cmd | grep bash | awk '{rss+=$1;virt+=$2}END{print "COUNT: " NR; print "RESIDENT: " int(rss/1024) " MB"; print "VIRTUAL: " int(virt/1024) " MB"}'
COUNT: 4
RESIDENT: 3 MB
VIRTUAL: 13 MB

$ ps -Ao rss,vsize,cmd | grep fish | awk '{rss+=$1;virt+=$2}END{print "COUNT: " NR; print "RESIDENT: " int(rss/1024) " MB"; print "VIRTUAL: " int(virt/1024) " MB"}'
COUNT: 5
RESIDENT: 8 MB
VIRTUAL: 23 MB

Hmmm ... I should try this when I'm doing real work.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#5 2010-07-04 19:25:15

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Why Are Multiple Shell Instances Necessary?

I suggest dash and f.e. 'urxvtc -e htop'.

Offline

#6 2010-07-04 20:01:36

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: Why Are Multiple Shell Instances Necessary?

I guess I shouldn't feel guilty about ~2MB per shell.

I do wonder why exactly you cannot have multiple terminals hooked into the same shell instance. I guess figuring where stdout goes is difficult?

Offline

#7 2010-07-05 00:23:21

Cadynum
Member
Registered: 2010-04-15
Posts: 20

Re: Why Are Multiple Shell Instances Necessary?

If you want to launch something from a shell, without having the shell "underneath", use exec:

exec irssi

Offline

#8 2010-07-05 07:32:13

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Why Are Multiple Shell Instances Necessary?

% ps -Ao rss,vsize,cmd | grep zsh | awk '{rss+=$1;virt+=$2}END{print "COUNT: " NR; print "RESIDENT: " int(rss/1024) " MB"; print "VIRTUAL: " int(virt/1024) " MB"}' 
COUNT: 11
RESIDENT: 14 MB
VIRTUAL: 63 MB

(Note it's zsh)

Since i switched to zsh it does take less ram and lots less startup time (i mean starting a terminal and the shell only takes maybe a second or so, not as with bash 5).

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#9 2010-07-05 13:35:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Why Are Multiple Shell Instances Necessary?

@ Ogion
bash in urxvt here - starts in definitely less than a second. Were you using bash-completion or what?

Offline

#10 2010-07-05 14:37:14

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Why Are Multiple Shell Instances Necessary?

Oh, ofc i was using bash-completion. Also my bashrc wasn't really long, just a bunch of aliases. My zsh config now is longer than what i did to bashrc and it starts faster and uses less ram. (And comes with its lovely completion smile )

Ogion

Last edited by Ogion (2010-07-05 14:37:35)


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#11 2010-07-05 15:34:58

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: Why Are Multiple Shell Instances Necessary?

It's nice to see zsh has a smaller memory footprint, which was kinda unexpected for me. I have been contemplating switching for a while. My bash starts instantly, but I have had to disable bash-completion to do so, otherwise it takes ~1 sec which is too slow for me wink .

I'd still like to understand WHY multiple shell instances are necessary --- I don't know much about the way they work. I would expect the only difficulty with hooking multiple clients into one shell would be where the stdout goes. Obviously the shell would have to keep a list of the connected clients, and the clients would need a bit of memory.

Offline

#12 2010-07-05 15:37:52

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Why Are Multiple Shell Instances Necessary?

@ egan
You can background apps: bg, fg, jobs etc.

> where the stdout goes
It goes where you tell it to go, you can always redirect.

Offline

#13 2010-07-05 16:45:06

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: Why Are Multiple Shell Instances Necessary?

karol wrote:

@ egan
You can background apps: bg, fg, jobs etc.

> where the stdout goes
It goes where you tell it to go, you can always redirect.

Yes I know job control and such, I don't really see how that is related.

I know where stdout goes and how to redirect it --- I just wondered if that was a possible consideration as to WHY it is necessary for multiple, complete shell instances.
Why is it not possible to have one shell managing things with clients (in different terminals) hooked into it to give it commands?
Another consideration I realize is that blocking processes (not backgrounded or immediately returning) would preclude the clients from communicating with out the shell forking?

Offline

#14 2010-07-05 17:28:24

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Why Are Multiple Shell Instances Necessary?

As far as i saw it as i was using it for a while, fish seems to have a daemon-client thing running.

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

Board footer

Powered by FluxBB