-/**
- * Creates the supervisor socket for 'path' and return it
- * return -1 in case of failure
- */
-static int create_supervision_socket(const char *path)
-{
- int fd, rc;
- struct sockaddr_un addr;
- size_t length;
-
- /* check the path's length */
- length = strlen(path);
- if (length >= 108) {
- ERROR("Path name of supervision socket too long: %d", (int)length);
- errno = ENAMETOOLONG;
- return -1;
- }
-
- /* create a socket */
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- ERROR("Can't create socket: %m");
- return fd;
- }
-
- /* setup the bind to a path */
- memset(&addr, 0, sizeof addr);
- addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, path);
- if (addr.sun_path[0] == '@')
- addr.sun_path[0] = 0; /* abstract sockets */
- else
- unlink(path);
-
- /* binds the socket to the path */
- rc = bind(fd, (struct sockaddr *) &addr, (socklen_t)(sizeof addr));
- if (rc < 0) {
- ERROR("can't bind socket to %s", path);
- close(fd);
- return rc;
- }
- return fd;
-}
-