Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. const char* marp = move_as_root_path();
  2. pid_t pid = fork();
  3. if (pid == 0) {
  4. if (fds[1] != 1) {
  5. dup2(fds[1], 1);
  6. close(fds[1]);
  7. }
  8. close(fds[0]);
  9. execl(marp, marp, file_cstr, NULL);
  10. _exit(0);
  11. } else if (pid != -1) {
  12. close(fds[1]);
  13. char buf[1024];
  14. size_t actual_size;
  15. NSMutableData* data = [[NSMutableData alloc] init];
  16. while ((actual_size = read(fds[0], buf, 1024)) > 0)
  17. [data appendBytes:buf length:actual_size];
  18. close(fds[0]);
  19. file_content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  20. [data release];
  21. }
Add Comment
Please, Sign In to add comment