Skip to content

Instantly share code, notes, and snippets.

@saagarjha
Last active March 22, 2019 04:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saagarjha/8b8e4647646e4477370db6b2680e8ebc to your computer and use it in GitHub Desktop.
Save saagarjha/8b8e4647646e4477370db6b2680e8ebc to your computer and use it in GitHub Desktop.
Simple dynamic library that, when injected, pauses programs during initialization
// Dynamic library that pauses a short lived program during launch so that a
// debugger can attach to it. To use it, compile it on macOS:
// clang -dynamiclib pause4debug.c -o pause4debug.dylib
// On Linux:
// gcc -shared -fPIC pause4debug.c -o pause4debug.so
// To use it, make the dynamic linker inject it using DYLD_INSERT_LIBRARIES or
// LD_PRELOAD, depending on your platform. On macOS:
// DYLD_INSERT_LIBRARIES=/path/to/pause4debug.dylib debugme
// On Linux,
// LD_PRELOAD=/path/to/pause4debug.so debugme
#include <unistd.h>
__attribute__((constructor)) void init() {
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment