s6

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

s6_fdholder_retrieve.c (726B)


      1 /* ISC license. */
      2 
      3 #include <errno.h>
      4 #include <skalibs/allreadwrite.h>
      5 #include <skalibs/tai.h>
      6 #include <skalibs/unixmessage.h>
      7 #include <s6/fdholder.h>
      8 
      9 int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dodelete, tain const *deadline, tain *stamp)
     10 {
     11   unixmessage m ;
     12   s6_fdholder_retrieve_result_t res ;
     13   if (!s6_fdholder_retrieve_maybe_delete_async(a, id, dodelete)) return -1 ;
     14   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ;
     15   if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ;
     16   if (!s6_fdholder_retrieve_cb(&m, &res)) return -1 ;
     17   if (res.err) return (errno = res.err, -1) ;
     18   return res.fd ;
     19 }