summaryrefslogtreecommitdiff
path: root/src/libs6/s6_fdholder_list.c
blob: d86049f5eb4a7e5b2e7c6964922c509c36f83e30 (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/s6-fdholder.h>

int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain_t const *deadline, tain_t *stamp)
{
  s6_fdholder_list_result_t res = { .sa = sa } ;
  unixmessage_t 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 ;
}