summaryrefslogtreecommitdiff
path: root/src/libstddjb/ipc_connected.c
blob: 310649b521d7609d67de6094515466c4ef5091dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <sys/un.h>

#include <skalibs/allreadwrite.h>
#include <skalibs/socket.h>

int ipc_connected (int s)
{
  struct sockaddr_un sa ;
  socklen_t dummy = sizeof sa ;
  if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
  {
    char ch ;
    fd_read(s, &ch, 1) ;
    return 0 ;
  }
  return 1 ;
}