Example #1
0
int
main(int argc, char **argv)
{
    if (argc < 2) {
        (void) fprintf(stderr, "Usage: %s <command> ...\n", argv[0]);
        exit(1);
    }

    rotate_logs();
    redirect_output();
    dump_privs();
    dump_args(argc, argv);

    /* print the header for the output from the program we exec (pre-flush) */
    (void) puts("=== OUTPUT ===");

    /* flush before next cmd takes over */
    (void) fflush(stdout);
    (void) fflush(stderr);

    exec_next(argc, argv);

    /* if we got here, we failed */
    (void) fprintf(stderr, "FATAL: execvp() failed.\n");
    exit(1);
}
Example #2
0
int
main(int argc, char **argv)
{
    time_t now;
    char time_buffer[32];

    if (argc < 2) {
        (void) fprintf(stderr, "Usage: %s <command> ...\n", argv[0]);
        exit(1);
    }

    rotate_logs();
    redirect_output();
    disable_cores();
    dump_privs();
    dump_args(argc, argv);

    /* get the current time for the log */
    time(&now);
    cftime(time_buffer, "%Y-%m-%dT%H:%M:%SZ", &now);

    /* print the header for the output from the program we exec (pre-flush) */
    (void) printf("=== OUTPUT (%s) ===\n", time_buffer);

    /* flush before next cmd takes over */
    (void) fflush(stdout);
    (void) fflush(stderr);

    exec_next(argc, argv);

    /* if we got here, we failed */
    (void) fprintf(stderr, "FATAL: execvp() failed.\n");
    exit(1);
}