liblinux++

A hosted C++ runtime without any libc.
git clone git://henryandlizzy.uk/liblinux++
Log | Files | Refs

tee.cpp (367B)


      1 #include "linux.hpp"
      2 #include "vector.hpp"
      3 
      4 int main(int argc, char* argv[])
      5 {
      6   vector<file> files;
      7   for (int i = 1; i < argc; ++i)
      8     files.push_back(*openat(AT_FDCWD, argv[i], O_WRONLY | O_CREAT, 0666));
      9 
     10   char buf[0x1000];
     11   for (;;)
     12   {
     13     auto n = *read(stdin, span{buf});
     14     if (not n)
     15       break;
     16     for (auto f : files)
     17       *write(f, buf, n);
     18   }
     19 }