<commit_before>

// not finished
// author: <EMAIL>


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <wvstream.h>

#include "wvdialmon.h"


WvStream *pppd_log = NULL;	// to read messages of pppd

WvDialMon pppd_mon;


int main( int argc, char ** argv )
{
  int argc_ppp = 0;
  char *argv_ppp[ argc+10 ];
  
  argv_ppp[argc_ppp++] = "/usr/sbin/pppd";
  
  for( int i = 1; i < argc; i++ )
    argv_ppp[argc_ppp++] = argv[i];
  
  
  // open a pipe to access the messages of pppd
  int pppd_msgfd[2];
  if( pipe( pppd_msgfd ) == -1 ) {
    fprintf( stderr, "pipe failed: %s\n", strerror(errno) );
    exit( EXIT_FAILURE );
  }
  
  char buffer[20];
  sprintf( buffer, "%d", pppd_msgfd[1] );
  argv_ppp[argc_ppp++] = "logfd";
  argv_ppp[argc_ppp++] = buffer;
  
  pppd_log = new WvStream( pppd_msgfd[0] );
  
  pppd_mon.setconnectmsg( "Connected..." );
  
  
  /*
  for( int i = 0; i < argc_ppp; i++ )
    printf( "%s\n", argv_ppp[i] );
  */
  

  // fork and exec pppd
  pid_t pid = fork();
  
  if( pid == (pid_t) 0 ) {	// we are the child
    argv_ppp[argc_ppp] = NULL;
    execv( argv_ppp[0], argv_ppp );
    fprintf( stderr, "exec failed: %s\n", strerror(errno) );
    exit( EXIT_FAILURE );
  }
  
  if( pid < (pid_t) 0 ) {	// the fork failed
    fprintf( stderr, "error: can't fork child process\n" );
    exit( EXIT_FAILURE );
  }

  
  /*
  ppp_pipe = new WvPipe( argv_ppp[0], argv_ppp, false, false, false );<commit_msg>Made wvfork() even safer. Also minor changes to WvPrintService.<commit_after>

// not finished
// author: <EMAIL>


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <wvstream.h>

#include "wvdialmon.h"
#include "wvfork.h"


WvStream *pppd_log = NULL;	// to read messages of pppd

WvDialMon pppd_mon;


int main( int argc, char ** argv )
{
  int argc_ppp = 0;
  char *argv_ppp[ argc+10 ];
  
  argv_ppp[argc_ppp++] = "/usr/sbin/pppd";
  
  for( int i = 1; i < argc; i++ )
    argv_ppp[argc_ppp++] = argv[i];
  
  
  // open a pipe to access the messages of pppd
  int pppd_msgfd[2];
  if( pipe( pppd_msgfd ) == -1 ) {
    fprintf( stderr, "pipe failed: %s\n", strerror(errno) );
    exit( EXIT_FAILURE );
  }
  
  char buffer[20];
  sprintf( buffer, "%d", pppd_msgfd[1] );
  argv_ppp[argc_ppp++] = "logfd";
  argv_ppp[argc_ppp++] = buffer;
  
  pppd_log = new WvStream( pppd_msgfd[0] );
  
  pppd_mon.setconnectmsg( "Connected..." );
  
  
  /*
  for( int i = 0; i < argc_ppp; i++ )
    printf( "%s\n", argv_ppp[i] );
  */
  

  // fork and exec pppd
  pid_t pid = wvfork();
  
  if( pid == (pid_t) 0 ) {	// we are the child
    argv_ppp[argc_ppp] = NULL;
    execv( argv_ppp[0], argv_ppp );
    fprintf( stderr, "exec failed: %s\n", strerror(errno) );
    exit( EXIT_FAILURE );
  }
  
  if( pid < (pid_t) 0 ) {	// the fork failed
    fprintf( stderr, "error: can't fork child process\n" );
    exit( EXIT_FAILURE );
  }

  
  /*
  ppp_pipe = new WvPipe( argv_ppp[0], argv_ppp, false, false, false );
{'fraction_non_alphanumeric': 0.16765285996055226, 'fraction_numerical': 0.009861932938856016, 'mean_word_length': 2.901282051282051, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 17, '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': '3124831', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1337, 'n_words': 316}