ipc_connect.c (573B)
1 /* ISC license. */ 2 3 #include <skalibs/nonposix.h> 4 #include <errno.h> 5 #include <sys/socket.h> 6 #include <sys/un.h> 7 #include <string.h> 8 9 #include <skalibs/socket.h> 10 #include <skalibs/posixishard.h> 11 12 int ipc_connect (int s, char const *p) 13 { 14 struct sockaddr_un sa ; 15 size_t l = strlen(p) ; 16 if (l > IPCPATH_MAX) return (errno = EPROTO, 0) ; 17 memset(&sa, 0, sizeof sa) ; 18 sa.sun_family = AF_UNIX ; 19 memcpy(sa.sun_path, p, l+1) ; 20 if (connect(s, (struct sockaddr *)&sa, sizeof sa) == -1) 21 { 22 if (errno == EINTR) errno = EINPROGRESS ; 23 return 0 ; 24 } 25 return 1 ; 26 }