3

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

yves Baumes
  • 268
  • 4
  • 9

2 Answers2

2

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.

Glorfindel
  • 1,213
  • 3
  • 15
  • 22
Allen
  • 1,315
  • 7
  • 12
0

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.