static int run_builtin(struct cmd_struct *p, int argc, const char **argv) { int status; struct stat st; const char *prefix; prefix = NULL; if (p->option & RUN_SETUP) prefix = NULL; /* setup_perf_directory(); */ if (use_browser == -1) use_browser = check_tui_config(p->cmd); if (use_pager == -1 && p->option & RUN_SETUP) use_pager = check_pager_config(p->cmd); if (use_pager == -1 && p->option & USE_PAGER) use_pager = 1; commit_pager_choice(); set_debugfs_path(); status = p->fn(argc, argv, prefix); exit_browser(status); if (status) return status & 0xff; /* Somebody closed stdout? */ if (fstat(fileno(stdout), &st)) return 0; /* Ignore write errors for pipes and sockets.. */ if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) return 0; /* Check for ENOSPC and EIO errors.. */ if (fflush(stdout)) die("write failure on standard output: %s", strerror(errno)); if (ferror(stdout)) die("unknown write failure on standard output"); if (fclose(stdout)) die("close failed on standard output: %s", strerror(errno)); return 0; }
static int run_builtin(struct cmd_struct *p, int argc, const char **argv) { int status; struct stat st; const char *prefix; prefix = NULL; if (p->option & RUN_SETUP) prefix = NULL; if (use_browser == -1) use_browser = check_tui_config(p->cmd); if (use_pager == -1 && p->option & RUN_SETUP) use_pager = check_pager_config(p->cmd); if (use_pager == -1 && p->option & USE_PAGER) use_pager = 1; commit_pager_choice(); status = p->fn(argc, argv, prefix); exit_browser(status); if (status) return status & 0xff; if (fstat(fileno(stdout), &st)) return 0; if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) return 0; if (fflush(stdout)) die("write failure on standard output: %s", strerror(errno)); if (ferror(stdout)) die("unknown write failure on standard output"); if (fclose(stdout)) die("close failed on standard output: %s", strerror(errno)); return 0; }