stracing pwd
Hellow. This just striked me.
I wondered how pwd works, I entered a linked directory, and pwd gives me the link.
when I tried pwd -h (wrong argument) I saw there are two possible arguments
I have/usr/src/linux-2.6.7/usr/src/linux -> /usr/src/linux-2.6.7
under /usr/src/linux,
pwd prints /usr/src/linux
pwd -L too
pwd -P prints /usr/src/linux-2.6.7
but an strace always shows the samewrite(1, "/usr/src/linux-2.6.7\n", 21/usr/src/linux-2.6.7 ) = 21
and it prints /usr/src/linux-2.6.7 to stdout no matter the parameter given to pwd.
Anyone knows why that could happen?
( I haven't seen to the pwd code yet though)
Quoted 13 lines · David Eduardo Gómez Noguera
/usr/src/linux-2.6.7/usr/src/linux->/usr/src/linux-2.6.7under
/usr/src/linux,
pwd prints/usr/src/linux
pwd -L too
pwd -P prints/usr/src/linux-2.6.7
but an strace always shows the samewrite(1, "/usr/src/linux-2.6.7\n", 21/usr/src/linux-2.6.7 )= 21
and it prints/usr/src/linux-2.6.7to stdout no matter the parameter given to pwd.
Quoted 2 lines
Anyone knows why that could happen?
( I haven't seen to the pwd code yet though)
The difference is that the first time you call pwd, you actually call the shell builtin named pwd. The second time you call pwd, you call /bin/pwd. The shell thinks you are where you have cd'd to, but in fact, you are in /usr/src/linux-2.6.7. Just try typing /bin/pwd in the shell.
Cheers,
Christoph
Signature · 8 lines
``There's no dark side of the moon, really Matter of fact, it's all dark'' --Pink Floyd - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html