mthdcat.cc 395 B

123456789101112131415161718192021
  1. /* Usage, mthdcat < cmds | methods/mthd
  2. All this does is cat a file into the method without closing the FD when
  3. the file ends */
  4. #include <unistd.h>
  5. int main()
  6. {
  7. char Buffer[4096];
  8. while (1)
  9. {
  10. int Res = read(STDIN_FILENO,Buffer,sizeof(Buffer));
  11. if (Res <= 0)
  12. while (1) sleep(100);
  13. if (write(STDOUT_FILENO,Buffer,Res) != Res)
  14. break;
  15. }
  16. return 0;
  17. }