<commit_before>// init: The initial user-level program

#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"

char *argv[] = { "sh", 0 };

int
main(void)
{
  int pid, wpid;

  if(open("console", O_RDWR) < 0){
    mknod("console", 1, 1);
    open("console", O_RDWR);
  }
  dup(0);  // stdout
  dup(0);  // stderr

  if (mknod("netif", 2, 1) < 0)
      printf(2, "init: mknod netif failed\n");
  if (mknod("sampler", 3, 1) < 0)
      printf(2, "init: mknod sampler failed\n");

  for(;;){
    pid = fork(0);
    if(pid < 0){
      printf(1, "init: fork failed\n");
      exit();
    }
    if(pid == 0){
      exec("sh", argv);
      printf(1, "init: exec sh failed\n");
      exit();
    }
    while((wpid=wait()) >= 0 && wpid != pid)
      printf(1, "zombie!\n");<commit_msg>Modify init to start telnetd and httpd if using lwIP<commit_after>// init: The initial user-level program

#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
#include "lib.h"

static char *sh_argv[] = { "sh", 0 };
static char *app_argv[][MAXARG] = {
#ifdef LWIP
  { "telnetd", 0 },
  { "httpd", 0 },
#endif
};

static int
startone(char **argv)
{
  int pid;

  pid = fork(0);
  if(pid < 0){
    printf(1, "init: fork failed\n");
    exit();
  }
  if(pid == 0){
    exec(argv[0], argv);
    printf(1, "init: exec %s failed\n", argv[0]);
    exit();
  }
  return pid;
}

int
main(void)
{
  int pid, wpid;

  if(open("console", O_RDWR) < 0){
    mknod("console", 1, 1);
    open("console", O_RDWR);
  }
  dup(0);  // stdout
  dup(0);  // stderr

  if (mknod("netif", 2, 1) < 0)
      printf(2, "init: mknod netif failed\n");
  if (mknod("sampler", 3, 1) < 0)
      printf(2, "init: mknod sampler failed\n");

  for (int i = 0; i < NELEM(app_argv); i++)
    startone(app_argv[i]);

  for(;;){
    pid = startone(sh_argv);
    while((wpid=wait()) >= 0 && wpid != pid)
      printf(1, "zombie!\n");
{'fraction_non_alphanumeric': 0.21267679413305396, 'fraction_numerical': 0.02462022001047669, 'mean_word_length': 2.8821138211382116, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 5, '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': '6994133', 'n_tokens_mistral': 841, 'n_tokens_neox': 801, 'n_words': 202}