Advertisement
Guest User

yeboy

a guest
Oct 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Named pipes
  2. ==========
  3. mkfifo /tmp/pipe
  4. echo Greetings > /tmp/pipe
  5. cat /tmp/pipe
  6.  
  7. Shell pipes
  8. ==========
  9. date | cat
  10. ps aux | grep cron (vs pgrep)
  11.  
  12. Unix sockets
  13. ==========
  14. - nc -lkU aSocket.sock
  15. - More than two processes
  16. - Bidirectional
  17. - UID / GID credentials
  18. - File descriptors
  19. - Packet modes
  20. - send() / recv() vs write / read()
  21.  
  22. SHM
  23. ==========
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <sys/mman.h>
  27.  
  28. void* create_shared_memory(size_t size) {
  29. // Our memory buffer will be readable and writable:
  30. int protection = PROT_READ | PROT_WRITE;
  31.  
  32. // The buffer will be shared (meaning other processes can access it), but
  33. // anonymous (meaning third-party processes cannot obtain an address for it),
  34. // so only this process and its children will be able to use it:
  35. int visibility = MAP_SHARED | MAP_ANONYMOUS;
  36.  
  37. // The remaining parameters to `mmap()` are not important for this use case,
  38. // but the manpage for `mmap` explains their purpose.
  39. return mmap(NULL, size, protection, visibility, -1, 0);
  40. }
  41.  
  42. Memory- mapped files
  43. ==========
  44. - Load a file in memory
  45. - When a process does a read write it does in the file
  46. - FD reference
  47. - Faster?
  48. - lsof | grep mem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement