s6

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

ftrigw_notifyb.c (508B)


      1 /* ISC license. */
      2 
      3 #include <errno.h>
      4 #include <signal.h>
      5 
      6 #include <s6/ftrigw.h>
      7 
      8 int ftrigw_notifyb (char const *path, char const *s, size_t len)
      9 {
     10   struct sigaction old ;
     11   struct sigaction action = { .sa_handler = SIG_IGN, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ;
     12   int r ;
     13   sigfillset(&action.sa_mask) ;
     14   if (sigaction(SIGPIPE, &action, &old) == -1) return -1 ;
     15   r = ftrigw_notifyb_nosig(path, s, len) ;
     16   {
     17     int e = errno ;
     18     sigaction(SIGPIPE, &old, 0) ;
     19     errno = e ;
     20   }
     21   return r ;
     22 }