mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-05 05:09:21 +02:00
Merge branch 'tracerpid-abort' into 'main'
gmessages: Check /proc/self/status for TracerPid != 0 before sending SIGTRAP Closes #3790 See merge request GNOME/glib!4845
This commit is contained in:
@@ -421,8 +421,30 @@ _g_log_abort (gboolean breakpoint)
|
|||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
debugger_present = IsDebuggerPresent ();
|
debugger_present = IsDebuggerPresent ();
|
||||||
|
#elif defined(G_OS_UNIX)
|
||||||
|
gchar *proc_status = NULL;
|
||||||
|
gsize len;
|
||||||
|
|
||||||
|
/* It's possible for /proc to exist on *BSD as well, so we will
|
||||||
|
* attempt to read the file regardless.
|
||||||
|
*/
|
||||||
|
if (g_file_get_contents ("/proc/self/status",
|
||||||
|
&proc_status,
|
||||||
|
&len,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
/* First, check if the line even exists... */
|
||||||
|
if (g_strstr_len (proc_status, len, "TracerPid:"))
|
||||||
|
debugger_present = (g_strstr_len (proc_status, len, "TracerPid:\t0") == NULL);
|
||||||
|
else /* Otherwise, very likely not debugging. */
|
||||||
|
debugger_present = FALSE;
|
||||||
|
}
|
||||||
|
else /* The file likely doesn't exist, so we'll just assume we are debugging. */
|
||||||
|
debugger_present = TRUE;
|
||||||
|
|
||||||
|
g_free (proc_status);
|
||||||
#else
|
#else
|
||||||
/* Assume GDB is attached. */
|
/* Assume debugger is attached. */
|
||||||
debugger_present = TRUE;
|
debugger_present = TRUE;
|
||||||
#endif /* !G_OS_WIN32 */
|
#endif /* !G_OS_WIN32 */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user