Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. srand(time(NULL)*getpid());
  2. int s = (10 + rand()%101)*1024;
  3. char name[sizeof(getpid()) + 4];
  4. sprintf(name, "%d", getpid());
  5. name[4] = '.';
  6. name[5] = 't';
  7. name[6] = 'x';
  8. name[7] = 't';
  9. char* buf = malloc(1);
  10. if(!buf)
  11. ERR("malloc");
  12. buf[0] = n + '0';
  13.  
  14. if((out = TEMP_FAILURE_RETRY(open(name, O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, 0777))) < 0)
  15. ERR("open");
  16. for(int i=0; i<1; i++)
  17. {
  18. for(int i=0; i<s; i++)
  19. if((c = bulk_write(out, buf, 4)) < 0)
  20. ERR("write");
  21. TEMP_FAILURE_RETRY(fprintf(stderr, "Block of %d bytes transfered.\n", s*4));
  22. }
  23.  
  24. if(TEMP_FAILURE_RETRY(close(out)))
  25. ERR("close");
  26. free(buf);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement