Weekend trivia: your process' memory is a file
16 hours ago
- #System Debugging
- #Unix Philosophy
- #Memory Access
- The Unix design philosophy 'everything is a file' is not fully realized, as some OS functionality like TCP/IP connections requires special system calls or workarounds, such as bash's /dev/tcp trick.
- Process identifiers (PIDs) and file descriptors are separate, though Linux offers limited conversion via a system call, and /proc provides process metadata, but accessing /proc/<pid>/mem requires specific offsets via lseek, pread, or pwrite.
- /proc/<pid>/mem allows real-time memory access and modification of a target process, offering an elegant alternative to the janky ptrace debugging interface, exemplified by tools like memfetch for memory screenshots.
- Historically, mmap on /proc/<pid>/mem was possible but caused system instability and was removed, highlighting the balance between functionality and reliability in system APIs.