<commit_before>/*
 * This file is covered by the Internet Software Consortium (ISC) License
 * Reference: ../License.txt
 *
 * The first argument is the path to the log
 * The second argument is "0" or "1", where "1" sets the process group
 * The remaining arguments are passed to the spawn
 * We expect a minimum of 4 arguments
 */

#include <unistd.h>
#include <string.h>
#include <fcntl.h>

int main (int argc, char *argv[])
{
  if (argc < 5)
    {
      return (-2);
    }

  int fd = open (argv[1], O_RDWR | O_APPEND | O_CREAT, 0644);
  if (fd < 0)
    {
      return (-3);
    }

  dup2 (fd, STDOUT_FILENO);
  dup2 (fd, STDERR_FILENO);
  close (fd);

  if (strncmp (argv[2], "1", 1) == 0)
  {
    int result = setpgid (0, 0);
    if (result != 0)
      {
        return (-4);
      }
  }
  return execv (argv[3], (argv + 3));
}<commit_msg>Sanitize synthexec helper (issue #52)<commit_after>/*
 * This file is covered by the Internet Software Consortium (ISC) License
 * Reference: ../License.txt
 *
 * The first argument is the path to the log
 * The second argument is "0" or "1", where "1" sets the process group
 * The remaining arguments are passed to the spawn
 * We expect a minimum of 4 arguments
 */

#include <unistd.h>
#include <string.h>
#include <fcntl.h>

int main (int argc, char *argv[])
{
  if (argc < 5)
    {
      return (-2);
    }

  int fd = open (argv[1], O_RDWR | O_APPEND | O_CREAT, 0644);
  if (fd < 0)
    {
      return (-3);
    }
  if (fd <= STDERR_FILENO)
    {
      return (-5);
    }

  dup2 (fd, STDOUT_FILENO);
  dup2 (fd, STDERR_FILENO);
  close (fd);

  if (strncmp (argv[2], "1", 1) == 0)
  {
    int result = setpgid (0, 0);
    if (result != 0)
      {
        return (-4);
      }
  }
  closefrom (3);
  return execv (argv[3], (argv + 3));
}
{'fraction_non_alphanumeric': 0.14868641699273338, 'fraction_numerical': 0.03018446059250978, 'mean_word_length': 2.5236220472440944, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 9, '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': '2320222', 'n_tokens_mistral': 698, 'n_tokens_neox': 661, 'n_words': 231}