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

#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
#include <skalibs/unixmessage.h>
#include <s6/fdholder.h>

int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain const *deadline, tain *stamp)
{
  s6_fdholder_list_result_t res = { .sa = sa } ;
  unixmessage m ;
  if (!s6_fdholder_list_async(a)) return -1 ;
  if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ;
  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ;
  if (!s6_fdholder_list_cb(&m, &res)) return -1 ;
  if (res.err) return (errno = res.err, -1) ;
  return (int)res.n ;
}