Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Named pipes
- ==========
- mkfifo /tmp/pipe
- echo Greetings > /tmp/pipe
- cat /tmp/pipe
- Shell pipes
- ==========
- date | cat
- ps aux | grep cron (vs pgrep)
- Unix sockets
- ==========
- - nc -lkU aSocket.sock
- - More than two processes
- - Bidirectional
- - UID / GID credentials
- - File descriptors
- - Packet modes
- - send() / recv() vs write / read()
- SHM
- ==========
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/mman.h>
- void* create_shared_memory(size_t size) {
- // Our memory buffer will be readable and writable:
- int protection = PROT_READ | PROT_WRITE;
- // The buffer will be shared (meaning other processes can access it), but
- // anonymous (meaning third-party processes cannot obtain an address for it),
- // so only this process and its children will be able to use it:
- int visibility = MAP_SHARED | MAP_ANONYMOUS;
- // The remaining parameters to `mmap()` are not important for this use case,
- // but the manpage for `mmap` explains their purpose.
- return mmap(NULL, size, protection, visibility, -1, 0);
- }
- Memory- mapped files
- ==========
- - Load a file in memory
- - When a process does a read write it does in the file
- - FD reference
- - Faster?
- - lsof | grep mem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement