I am running Ubuntu 14.04 (64 bit). When I first found out about the command xterm
, I tried the command xterm xterm
, and it started infinitely opening new xterm windows.
ctrl + C
stops it immediately and closes all windows.
But I wanted to see how far it goes and let it run as long as it can. It ate up almost all the RAM and eventually got closed (I think by the system itself).
So just out of curiosity, why/how does this happen?
I (guess) this is because the first parameter you give to
xterm
is the shell to use -xterm bash
(orxterm /bin/bash
),xterm python
etc.So it runs
xterm
, tries to startxterm
as a shell, which starts anotherxterm
as that ones shell, then another, and another...You can probably find a bit more on this by running
man xterm
Short version: xterm's argument is the shell to execute by xterm; shell is set in environment var, so further calls do a
10 PRINT "xterm" 20 GOTO 10
recursion.Long version:
xterm xterm
passesxterm
to xterm call as xterm's shell by setting$SHELL
variable toxterm
(1st parameter of xterm is interpreted as shell to execute)xterm xterm
command executes the$SHELL
- in this case, creating another xterm instance (because$SHELL=xterm
now)$SHELL=xterm
already, so the newly created xterm executesxterm
Further reading:
man xterm