<commit_before>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 * NOTE TO FreeBSD users. Install libexecinfo from 
 * ports/devel/libexecinfo and add -lexecinfo to LDFLAGS
 * to add backtrace support.
 */
#include "e.h"
#include <X11/Xlib.h>

static volatile Eina_Bool _e_x_composite_shutdown_try = 0;
static void
_e_x_composite_shutdown(void)
{
   Ecore_X_Display *dpy;
   Ecore_X_Window root;

   if (_e_x_composite_shutdown_try) return; /* we failed :-( */
   _e_x_composite_shutdown_try = 1;

   dpy = ecore_x_display_get();
   root = DefaultRootWindow(dpy);

   /* ignore errors, we really don't care at this point */
   ecore_x_composite_unredirect_subwindows(root, ECORE_X_COMPOSITE_UPDATE_MANUAL);
   _e_x_composite_shutdown_try = 0;
}

#define _e_write_safe(fd, buf) _e_write_safe_int(fd, buf, sizeof(buf))
static void
_e_write_safe_int(int fd, const char *buf, size_t size)
{
   while (size > 0)
     {
	ssize_t done = write(fd, buf, size);
	if (done >= 0)
	  {
	     buf += done;
	     size -= done;
	  }
	else
	  {
	     if ((errno == EAGAIN) || (errno == EINTR))
	       continue;
	     else
	       {
		  perror("write");
		  return;
	       }
	  }
     }
}

static void
_e_gdb_print_backtrace(int fd)
{
   char cmd[1024];
   size_t size;

   size = snprintf(cmd, sizeof(cmd),
		   "gdb --pid=%d "
		   "-ex 'thread apply all bt' "
		   "-ex detach -ex quit", getpid());
<commit_msg>Make it possible to disable the auto gdb backtrace.<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 * NOTE TO FreeBSD users. Install libexecinfo from 
 * ports/devel/libexecinfo and add -lexecinfo to LDFLAGS
 * to add backtrace support.
 */
#include "e.h"
#include <X11/Xlib.h>

static volatile Eina_Bool _e_x_composite_shutdown_try = 0;
static void
_e_x_composite_shutdown(void)
{
   Ecore_X_Display *dpy;
   Ecore_X_Window root;

   if (_e_x_composite_shutdown_try) return; /* we failed :-( */
   _e_x_composite_shutdown_try = 1;

   dpy = ecore_x_display_get();
   root = DefaultRootWindow(dpy);

   /* ignore errors, we really don't care at this point */
   ecore_x_composite_unredirect_subwindows(root, ECORE_X_COMPOSITE_UPDATE_MANUAL);
   _e_x_composite_shutdown_try = 0;
}

#define _e_write_safe(fd, buf) _e_write_safe_int(fd, buf, sizeof(buf))
static void
_e_write_safe_int(int fd, const char *buf, size_t size)
{
   while (size > 0)
     {
	ssize_t done = write(fd, buf, size);
	if (done >= 0)
	  {
	     buf += done;
	     size -= done;
	  }
	else
	  {
	     if ((errno == EAGAIN) || (errno == EINTR))
	       continue;
	     else
	       {
		  perror("write");
		  return;
	       }
	  }
     }
}

static void
_e_gdb_print_backtrace(int fd)
{
   char cmd[1024];
   size_t size;

   if(getenv("E_NO_GDB_BACKTRACE"))
     return;

   size = snprintf(cmd, sizeof(cmd),
		   "gdb --pid=%d "
		   "-ex 'thread apply all bt' "
		   "-ex detach -ex quit", getpid());

{'fraction_non_alphanumeric': 0.12422360248447205, 'fraction_numerical': 0.013112491373360938, 'mean_word_length': 3.232116788321168, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6301797', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1131, 'n_words': 254}