Fixing an Infinite Loop on Unix
Symlinks, Firmlinks, /dev, FIFO, and other magic words in Unix
Writing software often means hitting roadblocks you never see coming—and sometimes, the solution is much simpler than you think. Recently, I encountered an issue with my MachOFileFinder on MacOS. It led me down an exciting path involving links and recursive loops they create and various file structures, flags, and other stuff related to the Unix file system.
I would like to thank Gergely Kalman, who showed me where the source of the problem might be. I found out later that the root cause was different, but I learned some new things and refreshed my knowledge about Unix.
I am sure that many of you will find the rabbit holes described here and the solution to the problem both interesting and valuable.
Here’s the story of the bug, the solution, and what it taught me about macOS.
The story behind the bug
The tool I was working on is designed to locate Mach-O files in a macOS filesystem, identify their types, and optionally filter for ARM64 files.
I just updated it, so it is much faster. I described the whole process in the below article…