Casper H.S. Dik <Caspe...@OrSPaMcle.COM> writes:
>
gaz...@shell.xmission.com (Kenny McCormack) writes:
>>Casper H.S. Dik <Caspe...@OrSPaMcle.COM> wrote:
>>...
>>>>And wish they had /proc, like modern Unix (aka, Linux) does.
>>>
>>>Though Solaris has /proc, it does not adds anything other then
>>>process specific data, though in Solaris 11.4 that does include
>>>information about file descriptors such as most or all things
>>>you want to know of a socket.
>
>>Just FYI - and I have no desire to debate this furher - I am familiar with
>>Solaris /proc and have written programs that use it. I think we can agree
>>that Linux /proc is better, but I suppose one could debate "At what cost?".
>
> Hm, I'm not sure that is true. (Solaris procfs allows complete manipulation
> and not just information)
>
> I'm not quite sure that having the kernel convetring everything to
> ascii and processes like top converting it back.
>
> I think it more a question of philosophy if anything.
The idea is obviously that it's supposed to be possible to use the
information easily in environments where text processing is easy. This
would be interactive shells (or shell scripts) and higher-level
languages than C (including shell and Perl scripts). Ie, this was
designed based on the assumption that the information will mainly be
usuable to humans who'll mostly do fairly simple ad hoc programming if
at all or at least that this is also an important use case.
Eg, the quick way to solve the problem of finding processes owning a
certain listening socket is something like
[root@doppelsaurus]~ #printf "%x" 80
50[root@doppelsaurus]~ #grep :0050 /proc/net/tcp
1: 00000000:0050 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 4820 1 ffff880230740b40 100 0 0 10 0
[root@doppelsaurus]~ #find /proc/*/fd -ls | grep 4820
12504 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3142/fd/3 -> socket:[4820]
12575 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3219/fd/3 -> socket:[4820]
12612 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3221/fd/3 -> socket:[4820]
12649 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3223/fd/3 -> socket:[4820]
12686 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3225/fd/3 -> socket:[4820]
12723 0 lrwx------ 1 root root 64 Feb 26 15:09 /proc/3227/fd/3 -> socket:[4820]
I had to solve this problem based on BSD netstat and fstat in the past
and I had greatly preferred the above instead, not the least because
this was a customer-visible issue (listening socket leaked to random
process due to missing FD_CLOEXEC).