Debugging connect syscall with strace – what does @"sun_path" mean?

时间:2017-04-10 02:51:24

标签: sockets unix connect strace unix-socket

I've got two programs in different languages attempting to connect to a local abstract socket on a Linux system. One of the two is failing. I am having difficulty determining why. I just want to know what the one difference I can find in the strace output means, so I can fix it.

The working one has this strace output:

socket(PF_LOCAL, SOCK_SEQPACKET, 0)     = 3
connect(3, {sa_family=AF_LOCAL, sun_path=@"qwertystop.bus.8"}, 19) = 0

The nonworking has this strace output:

[pid  6307] socket(PF_LOCAL, SOCK_SEQPACKET, 0) = 13
[pid  6307] connect(13, {sa_family=AF_LOCAL, sun_path="qwertystop.bus.8"}, 19) = -1 ENOENT (No such file or directory)

There are three differences: The nonworking one is from a program with multiple pids, the return value of the connect call is different, and the working one has a @ before the sun_path string. I presume that whatever causes the @ to be missing is also what caused the failure, since it makes little sense for socket connection to not work in a process just because it was started by a different process.


(I am explicitly not requesting a general solution to "connect to an abstract socket", which is why I am not stating the languages. Mostly because this is homework and I refuse to create a situation which might tempt me to copy code directly.)

2 个答案:

答案 0 :(得分:0)

Meaning determined. It means the string is preceded by a null byte. Or possibly just a non-printing character, or it's signifying that the socket is abstract.

答案 1 :(得分:0)

我认为这是Linux的事情。见http://man7.org/linux/man-pages/man7/unix.7.html。它应该在“抽象插座”下。