From your posts, I suspect you want a cross platform solution.
First, I'll mention the Windows-only solution which is use IsDebuggerPresent() followed by an int 3. Code like this:
if IsDebuggerPresent() then asm int 3 end;
Quite simple but, unfortunately Windows only.
I presume there has to be a way under other operating systems (commonly Linux) to determine if a program is being debugged, if so, just implement your own version of IsDebuggerPresent() for that platform and problem solved.
HTH.