s6

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

s6_fdholder_delete.c (704B)


      1 /* ISC license. */
      2 
      3 #include <errno.h>
      4 
      5 #include <skalibs/allreadwrite.h>
      6 #include <skalibs/tai.h>
      7 #include <skalibs/unixmessage.h>
      8 
      9 #include <s6/fdholder.h>
     10 
     11 #include <skalibs/posixishard.h>
     12 
     13 int s6_fdholder_delete (s6_fdholder_t *a, char const *id, tain const *deadline, tain *stamp)
     14 {
     15   unixmessage m ;
     16   if (!s6_fdholder_delete_async(a, id)) return 0 ;
     17   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
     18   if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
     19   if (m.len != 1 || m.nfds)
     20   {
     21     unixmessage_drop(&m) ;
     22     return (errno = EPROTO, 0) ;
     23   }
     24   return m.s[0] ? (errno = (unsigned char)m.s[0], 0) : 1 ;
     25 }