skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

ipc_send.c (539B)


      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 ssize_t ipc_send (int fd, char const *s, size_t len, char const *path)
     13 {
     14   struct sockaddr_un sa ;
     15   size_t l = strlen(path) ;
     16   if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ;
     17   memset(&sa, 0, sizeof sa) ;
     18   sa.sun_family = AF_UNIX ;
     19   memcpy(sa.sun_path, path, l+1) ;
     20   return sendto(fd, s, len, 0, (struct sockaddr *)&sa, sizeof sa) ;
     21 }