int main(int argc, char *argv[]) {

    pager = getenv("PAGER");

    if (pager == NULL)
        pager = "less";

    /* Set number of processes and pipes depending on if we should run grep */
    args = (argc > 1) ? 1 : 0;
    num_procs = 3 + args;
    num_pipes = 2 + args;

    pipes_init();

    exec_proc(STDIN_FILENO, pipes[0][1], "printenv", argv); 

    if (args) {

        exec_proc(pipes[0][0], pipes[args][1], "grep", argv);
    }
    exec_proc(pipes[args][0], pipes[1 + args][1], "sort", argv);

    exec_proc(pipes[1 +args][0], STDOUT_FILENO, "less", argv);

    close_all_fd();

    wait_for_kids();

    return 0;
}
Exemple #2
0
static void init_all ()
{
    /* Look and stare at poor man's exception handling! */

    server_init();

    if ( ! buffer_init()) {
        server_final();
        exit(EXIT_FAILURE);
    }

    pipes_init();

    if ( ! sockets_init()) {
        pipes_final();
        buffer_final();
        server_final();
        exit(EXIT_FAILURE);
    }
}
Exemple #3
0
void sys_init(void) {
	pipes_init();

	timestamp_gen = malloc(sizeof(timestamp_gen_regs_t));
	software_timestamp_count = 0;
}