rizsotto/Bear — pull request #23 by breser (2013-04-25 00:06:38+00:00)
Title: OS X Compatability

I ported Bear to OS X. Along the way I switched from using some GNUisms to using POSIX functions. Reworked the expected.json to be produced by the test so that it can only produce output for implemented functions. Fixed the tests to use the CMAKE_SHARED_LIBRARY_SUFFIX var.

OS X has some quirks. Specifically environ isn't available in shared libraries. All the exec* functions call execve() and due to the way the library is written you override even the internal implementations in the C library, so only execve() needs to be trapped. It doesn't support LD_PRELOAD and instead uses DYLD_INSERT_LIBRARIES (and also needs DYLD_FORCE_FLAT_NAMESPACE).

The changes work for me on Linux and OS X. The only problem is the exec_anatomy test doesn't pass on OS X because the exec functions that support PATH (execvp and execlp) on OS X end up calling execve() to find out if the path exists until it finds the right one. I figure the solution to this is the changes you've got a ticket on about filtering failed calls since the dupes are the failed calls.

I may work on that ticket later but for the moment this solves my problem.