Advertisement
Guest User

Untitled

a guest
May 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. int variable, fd;
  2.  
  3. int do_something() {
  4. variable = 42;
  5. close(fd);
  6. _exit(0);
  7. }
  8.  
  9. int main(int argc, char *argv[]) {
  10. void **child_stack;
  11. char tempch;
  12.  
  13. variable = 9;
  14. fd = open("test.file", O_RDONLY);
  15. child_stack = (void **) malloc(16384);
  16. printf("The variable was %d\n", variable);
  17.  
  18. clone(do_something, child_stack, CLONE_VM|CLONE_FILES, NULL);
  19. sleep(1);
  20.  
  21. printf("The variable is now %d\n", variable);
  22. if (read(fd, &tempch, 1) < 1) {
  23. perror("File Read Error");
  24. exit(1);
  25. }
  26. printf("We could read from the file\n");
  27. re
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement