Пример #1
0
static void
run_status_loggers(struct invoke_hook *hook_head)
{
  struct invoke_hook *hook;

  for (hook = hook_head; hook; hook = hook->next) {
    pid_t pid;
    int p[2];

    m_pipe(p);

    pid = subproc_fork();
    if (pid == 0) {
      /* Setup stdin and stdout. */
      m_dup2(p[0], 0);
      close(1);

      close(p[0]);
      close(p[1]);

      command_shell(hook->command, _("status logger"));
    }
    close(p[0]);

    statusfd_add(p[1]);
  }
}
Пример #2
0
struct pager *
pager_spawn(const char *desc)
{
	struct sigaction sa;
	struct pager *pager;
	const char *exec;

	pager = m_calloc(1, sizeof(*pager));
	pager->used = isatty(0) && isatty(1);
	pager->desc = desc;

	exec = pager_get_exec();
	if (strcmp(exec, CAT) == 0)
		pager->used = false;

	if (!pager_enabled)
		pager->used = false;

	if (!pager->used)
		return pager;

	m_pipe(pager->pipe);

	memset(&sa, 0, sizeof(sa));
	sigemptyset(&sa.sa_mask);
	sa.sa_handler = SIG_IGN;
	sa.sa_flags = 0;

	sigaction(SIGPIPE, &sa, &pager->sigpipe);

	pager->pid = subproc_fork();
	if (pager->pid == 0) {
		/* Set better defaults for less if not already set. */
		setenv("LESS", "-FRSXMQ", 0);

		m_dup2(pager->pipe[0], 0);
		close(pager->pipe[0]);
		close(pager->pipe[1]);

		command_shell(exec, desc);
	}

	pager->stdout_old = m_dup(1);
	m_dup2(pager->pipe[1], 1);
	close(pager->pipe[0]);
	close(pager->pipe[1]);

	/* Force the output to fully buffered, because originally stdout was
	 * a tty, so it was set as line buffered. This way we send as much as
	 * possible to the pager, which will handle the output by itself. */
	setvbuf(stdout, NULL, _IOFBF, 0);

	return pager;
}
Пример #3
0
static void movecontrolfiles(const char *thing) {
  char buf[200];
  pid_t pid;

  sprintf(buf, "mv %s/* . && rmdir %s", thing, thing);
  pid = subproc_fork();
  if (pid == 0) {
    command_shell(buf, _("shell command to move files"));
  }
  subproc_reap(pid, _("shell command to move files"), 0);
}
Пример #4
0
static void movecontrolfiles(const char *thing) 
{
    char buf[200] = { '\0' };
    pid_t pid;

    snprintf(buf, sizeof(buf) - 1, "mv %s/* . && rmdir %s", thing, thing);
    pid = subproc_fork();
    if (pid == 0)
        command_shell(buf, "shell command to move files");

    subproc_reap(pid, "shell command to move files", 0);
}
Пример #5
0
int 
main (int argc, char *argv[])
{
	curses_init();

	void *ctx = zmq_ctx_new();

	command_shell(ctx);

	zmq_ctx_destroy(ctx);

	curses_end();
	return 0;
}
Пример #6
0
static int
run_logger(struct invoke_hook *hook, const char *name)
{
  pid_t pid;
  int p[2];

  m_pipe(p);

  pid = subproc_fork();
  if (pid == 0) {
    /* Setup stdin and stdout. */
    m_dup2(p[0], 0);
    close(1);

    close(p[0]);
    close(p[1]);

    command_shell(hook->command, name);
  }
  close(p[0]);

  return p[1];
}
Пример #7
0
void loop(void)
{
  command_shell();
 // while(1); //We should never get this far
}