示例#1
0
template <typename INT> void Node_Set<INT>::Display(std::ostream &s)
{
  Check_State();
  s << "Node_Set<INT>::Display_Stats()  Exodus node set ID = " << id_ << '\n'
    << "                              number of nodes = " << numEntity << '\n'
    << "               number of distribution factors = " << num_dist_factors << '\n'
    << "                          number of variables = " << var_count() << '\n';
}
示例#2
0
template <typename INT> void Exo_Block<INT>::Display_Stats(std::ostream &s) const
{
  s << "Exo_Block<INT>::Display()  block id = " << id_ << '\n'
    << "                  element type = " << elmt_type << '\n'
    << "               number of elmts = " << numEntity << '\n'
    << "      number of nodes per elmt = " << num_nodes_per_elmt << '\n'
    << "          number of attributes = " << attr_count() << '\n'
    << "           number of variables = " << var_count() << '\n';
}
示例#3
0
template <typename INT> void Exo_Block<INT>::Display(std::ostream &s) const
{
  SMART_ASSERT(Check_State());

  s << "Exo_Block<INT>::Display()  block id = " << id_ << '\n'
    << "                  element type = " << elmt_type << '\n'
    << "               number of elmts = " << numEntity << '\n'
    << "      number of nodes per elmt = " << num_nodes_per_elmt << '\n'
    << "          number of attributes = " << attr_count() << '\n'
    << "           number of variables = " << var_count() << '\n';

  if (conn) {
    size_t index = 0;
    s << "       connectivity = ";
    for (size_t e = 0; e < numEntity; ++e) {
      if (e != 0)
        s << "                      ";
      s << "(" << (e + 1) << ") ";
      for (int n = 0; n < num_nodes_per_elmt; ++n)
        s << conn[index++] << " ";
      s << '\n';
    }
  }
}
示例#4
0
/* execute another program, possibly searching for it first
 * 
 * if the 'exec' argument is set it will never return
 * ----------------------------------------------------------------------- */
int exec_program(char *path, char **argv, int exec, union node *redir) {
  int ret = 0;
  sigset_t nset, oset;
  
  /* if we're gonna execve() a program and 'exec' isn't 
     set or we aren't in the root shell environment we
     have to fork() so we can return */
  if(!exec || sh->parent) {
    pid_t pid;
    struct fdstack io;
    unsigned int n;

    fdstack_push(&io);

    /* buffered fds which have not a real effective file descriptor,
       like here-docs which are read from strallocs and command
       expansions, which write to strallocs can't be shared across
       different process spaces, so we have to establish pipes */
    if((n = fdstack_npipes(FD_HERE|FD_SUBST)))
      fdstack_pipe(n, fdstack_alloc(n));

    /* block child and interrupt signal, so we won't terminate ourselves
       when the child does */
    /*
    sigemptyset(&nset);
    sigaddset(&nset, SIGINT);

#ifdef SIGCHLD
    sigaddset(&nset, SIGCHLD);
#endif
    sigemptyset(&oset);
    sigprocmask(SIG_BLOCK, &nset, &oset);
*/
    sig_block();

    /* in the parent wait for the child to finish and then return 
       or exit, according to the 'exec' argument */
    if((pid = fork())) {
      int status = 1;

      /* this will close child ends of the pipes and read data from the parent end :) */
      fdstack_pop(&io);
      fdstack_data();

      
      job_wait(NULL, pid, &status, 0);
      job_status(pid, status);

      ret = WEXITSTATUS(status);

#ifndef __MINGW32__
      sigprocmask(SIG_SETMASK, &oset, NULL);
#endif
      
      /* exit if 'exec' is set, otherwise return */
      if(exec) sh_exit(ret);
      return ret;
    }

    /* ...in the child we always exit */
    sh_forked();
  }

  fdtable_exec();
  fdstack_flatten();

  /* when there is a path then we gotta execute a command,
     otherwise we exit/return immediately */
  if(path) {
    /* export environment */
    char **envp;
    unsigned long envn = var_count(V_EXPORT) + 1;
    envp = var_export(alloca(envn * sizeof(char *)));

    /* try to execute the program */
    execve(path, argv, envp);

    /* execve() returned so it failed, we're gonna map 
       the error code to the appropriate POSIX errors */
    ret = exec_error();

    /* yield an error message */
    sh_error(path);
  }

  /* we never return at this point! */
  exit(ret);
}