Operating systems limit the length of a path of a Unix domain socket. How can I check whether a particular path is within that limit?
Or, to put it another way, how can I check the maximum permitted length of a path of a Unix domain socket, on a Linux or Mac OS X system?
My use case here is for SSH multiplexing: if the ControlPath is too long, then SSH multiplexing won't work since it creates a unix domain sockets. I want to be able to check for a valid control path without having to actually start an ssh session and look for the error message.
On Linux, this length is usually defined as 108.
It is defined by the
UNIX_PATH_MAX
variable in the/usr/include/linux/un.h
header file :You could find further info here :
On Mac OS X, According to the
unix
man page:Here's a program that compiles on both Linux and OS X that will output the maximum length of the path of a unix domain socket.
On Linux, it outputs
108
, and on OS X, it outputs104
.