skalibs

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

trysplice.c (455B)


      1 /* ISC license. */
      2 
      3 #undef _POSIX_C_SOURCE
      4 #undef _XOPEN_SOURCE
      5 
      6 #ifndef _GNU_SOURCE
      7 #define _GNU_SOURCE
      8 #endif
      9 
     10 #include <fcntl.h>
     11 #include <sys/uio.h>
     12 
     13 int main (void)
     14 {
     15   char s[2][2] ;
     16   struct iovec v[2] = { { .iov_base = s[0], .iov_len = 2 }, { .iov_base = s[1], .iov_len = 2 } } ;
     17   loff_t in, out ;
     18   ssize_t r = splice(0, &in, 1, &out, 4096, SPLICE_F_MOVE) ;
     19   r = tee(0, 1, 4096, SPLICE_F_NONBLOCK) ;
     20   r = vmsplice(0, v, 2, 0) ;
     21   return 0 ;
     22 }