Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I listed open file for a process (a daemon) on my box which runs Mac OS X 10.5 :

>lsof  -p 89
COMMAND PID     USER   FD   TYPE    DEVICE  SIZE/OFF     NODE NAME
...
xxxxx   89 xxxxxxxx    9u  unix 0x34f8990       0t0          ->0x34f8880

I 'd like to find a way to open this socket and write in it. (that's my obsession this time ..)

How to find the i-node/name of the underlying file in order to reach that socket? Is there a way to address programatically this adress 0x34f888 from a shell script? If not so, how to do programatically ?

As a comment, I've launched the netstat command and get this result:

> netstat -u
Active LOCAL (UNIX) domain sockets
Address  Type   Recv-Q Send-Q    Inode     Conn     Refs  Nextref Addr
...
 34f8990 stream      0      0        0  34f8880        0        0
...
 34f8880 stream      0      0        0  34f8990        0        0
...

I am not a network/socket guru. Hope this could give more information

PS: to be honest I've posted this question on StackOverflow first (sorry, I don't think to ServerFault a first sight for now) but no one seems to give answer . :/ same question on SO

share|improve this question
    
this is really a programming question - please address the question there and not here. –  Alnitak May 14 '09 at 14:01

2 Answers 2

up vote 2 down vote accepted

It is possible for an AF_UNIX socket to be unbound to a filename, to be "unnamed", (or also "abstract" in which case is has a name but it has nothing to do with the filesystem) at least in Linux. It is unlikely that OS X is different. For details, see the man page for the socket function bind (or look in the dev docs).

Anyway, if OS X has the equivalent of the /proc filesystem you could possibly get a handle on the socket by going through the list of file descriptors of the target process. YMMV. Oops, it does not have a procfs. See this about Mac specific workarounds.

share|improve this answer

Unix domain sockets have inodes and can therefore be linked. You would normally expect them to manifest themselves as a special file somewhere in the file system.

share|improve this answer
    
What is the "mto manifest" ? Btw I was surprised to see in the netstat output that that socket does not have any i-node associated with . How to find it so ? –  yves Baumes May 14 '09 at 12:20
    
as someone who makes that kind of typo all the time, I'll answer =). "the mto" == "them to". –  jj33 May 14 '09 at 12:25
    
There, fixed. =8^o –  ConcernedOfTunbridgeWells May 14 '09 at 12:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.