pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, ye Monks of Perl.
I'm writing something that does a lot of readlink calls, and sometimes it returns some pretty strange stuff. I'm guessing the strangeness is actually coming from my operating system, but I wanted to share and see what you all thought.
Sometimes the returned string contains some non-printing characters followed by a bunch of pretty random looking stuff. Here's an example:
/proc/32433/exe -> /usr/bin/perl.pid]o_ff.jpg (deleted)
If I pipe that through less, I get to see markers showing me where the non-printing characters are:
/proc/32433/exe -> /usr/bin/perl^@.pid^@]^@^@o_ff.jpg (deleted)
An ordinary ls -l /proc/32433/exe says /proc/32433/exe -> /usr/bin/perl. I get the same by running the readlink command (/usr/bin/readlink).
So it looks like the correct answer followed by a bunch of other stuff.
If you're on linux, you can try this...
... and you might see what I'm talking about.find /proc -type l -name 'exe' | \ perl -n -e 'chomp($_); print "$_ -> ".readlink($_)."\n";'
Anybody know what's going on here?
I'm on CentOS 5.5 running perl 5.8.8 from the perl-5.8.8-32.el5_5.1 rpm package.
Thanks!
--Pileofrogs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: readlink returning strange stuff
by ikegami (Patriarch) on Aug 05, 2010 at 03:12 UTC | |
|
Re: readlink returning strange stuff
by aquarium (Curate) on Aug 05, 2010 at 01:42 UTC | |
by pileofrogs (Priest) on Aug 05, 2010 at 23:14 UTC | |
by choroba (Cardinal) on Aug 06, 2010 at 08:38 UTC | |
|
Re: readlink returning strange stuff
by oko1 (Deacon) on Aug 05, 2010 at 00:41 UTC |