a little puzzle
I was tinkering a little bit and I noticed something strange. I admit that I don't know the answer to this riddle (yet), but more than willing to let you shine your brilliant lights:
When I am in a terminal and I type Code:
while true Now where I got tinkering: Code:
while true So the big question is: why can't ps "see" all processes when called within a separate shell? Exercises to be done: what does it do within a script that calls a new shell (she-banged) Is this behaviour the same when doing this little joke as root. But first, can anyone solve this little riddle? |
The arguments -ef are not being passed to ps probably. Put "ps -ef" instead and it'll work. I'd guess that -ef are getting sent to bash...
|
You're correct, was searching myself in a totally different scope thing (thinking that the newly called shell was the reason for this behaviour.
Fun though ;-) Code:
while true |
hey I was more surprised that you were calling a new shell with $0. I always forget about the magic $ variables in bash!
|
I was actually looking at what'd happen with the $0 variable when I was calling it like this: in the do-while-loop. As predicted: it remained the shell's shell.
If you want it even more funny, I think this is possible in a script: #!`which $0` Up to you to predict what'll happen ;-) (actually, it's something worth tinkering about: as it'll bea script calling itself... FUN!) |
Quote:
|
Looks like a forkbomb, but I won't test it to find out ;)
|
This won't work; the characters following the shebang are interpreted by the kernel, not by the shell. That's also the reason why you always have to specify the whole path to an executable up there.
|
All times are GMT -5. The time now is 06:02 PM. |