예제 #1
0
파일: cmdexec.c 프로젝트: zsaleeba/shellbox
// Runs an internal toybox command. Returns the exit value.
int toy_run(struct toy_list *cmd, char *argv[])
{
    // Return if stack depth getting noticeable (proxy for leaked heap, etc).
    if (toys.stacktop && labs((char *)toys.stacktop-(char *)&cmd)>6000) {
      error_msg("stack full");
      return 1;
    }

    toy_init(cmd, argv);
    if (toys.which)
        toys.which->toy_main();

    return toys.exitval;
}
예제 #2
0
파일: main.c 프로젝트: OoOverflow/toybox
// Like exec() but runs an internal toybox command instead of another file.
// Only returns if it can't run command internally, otherwise exit() when done.
void toy_exec(char *argv[])
{
  struct toy_list *which;

  // Return if we can't find it (which includes no multiplexer case),
  if (!(which = toy_find(*argv))) return;

  // Return if stack depth getting noticeable (proxy for leaked heap, etc).
  if (toys.stacktop && labs((char *)toys.stacktop-(char *)&which)>6000)
    return;

  // Return if we need to re-exec to acquire root via suid bit.
  if (toys.which && (which->flags&TOYFLAG_ROOTONLY) && toys.wasroot) return;

  // Run command
  toy_init(which, argv);
  if (toys.which) toys.which->toy_main();
  xexit();
}
예제 #3
0
파일: main.c 프로젝트: jpmalkiewicz/ctoy
int main(int argc, char *argv[])
{
    struct display display;
    struct status status;
    struct entity *toy;

    display_init(&display);
    toy = toy_init();
    status_init(&status);

    while (!status.quit) {
        loop(&display, &status, toy);
    }

    status_deinit(&status);
    toy = toy->m->deinit(toy);
    display_deinit(&display);
    return 0;
}