<commit_before>#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/signal.h>
#include "../lib/sslib.h"
#include "../lib/daemon.h"



static int mainthread_loop(int argc,
			   char **argv,
			   struct dspd_daemon_ctx *ctx)
{
  while (1)
    {
      if ( ! dspd_wq_process(ctx->wq) )
	break;
    }
  return 0;
}

int main(int argc, char **argv)
{
  struct dspd_dict *sect;
  char **names, **files;
  size_t i;
  int ret = 0;
  signal(SIGPIPE, SIG_IGN);
  if ( (ret = dspd_daemon_init(argc, argv)) < 0 )
    {
      fprintf(stderr, "Error %d while initializing daemon\n", ret);
      return 1;
    }
  dspd_time_init();

  //sect = dict_read(fp);
<commit_msg>Find executable location instead of using argv[0] as is.  This fixes an issue with module path locations relative to the executable location not being found if dspd is executed without an absolute path.<commit_after>#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/signal.h>
#include "../lib/sslib.h"
#include "../lib/daemon.h"



static int mainthread_loop(int argc,
			   char **argv,
			   struct dspd_daemon_ctx *ctx)
{
  while (1)
    {
      if ( ! dspd_wq_process(ctx->wq) )
	break;
    }
  return 0;
}

int main(int argc, char **argv)
{
  struct dspd_dict *sect;
  char **names, **files;
  size_t i;
  int ret = 0;
  char *buf, *p;

  //Find the absolute path so module path lookups relative to the executable location
  //will work.
  if ( argv[0][0] != '/' )
    {
      buf = calloc(1, PATH_MAX+1UL);
      assert(buf != NULL);
      if ( buf )
	{
	  if ( readlink("/proc/self/exe", buf, PATH_MAX) > 0 )
	    {
	      p = strdup(buf);
	      assert(p != NULL);
	      if ( p )
		argv[0] = p;
	    }
	  free(buf);
	}
    }

  signal(SIGPIPE, SIG_IGN);
  if ( (ret = dspd_daemon_init(argc, argv)) < 0 )
    {
      fprintf(stderr, "Error %d while initializing daemon\n", ret);
      return 1;
    }
  dspd_time_init();

  //sect = dict_read(fp);

{'fraction_non_alphanumeric': 0.15029761904761904, 'fraction_numerical': 0.008432539682539682, 'mean_word_length': 2.770093457943925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, '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': '1404570', 'n_tokens_mistral': 812, 'n_tokens_neox': 773, 'n_words': 203}