| 850 | } |
| 851 | |
| 852 | bool Console::init(bool dont_redirect) |
| 853 | { |
| 854 | d = new Private(); |
| 855 | // make our own weird streams so our IO isn't redirected |
| 856 | if (dont_redirect) |
| 857 | { |
| 858 | d->dfout_C = fopen("/dev/stdout", "w"); |
| 859 | } |
| 860 | else |
| 861 | { |
| 862 | if (!freopen("stdout.log", "w", stdout)) |
| 863 | ; |
| 864 | d->dfout_C = fopen("/dev/tty", "w"); |
| 865 | if (!d->dfout_C) |
| 866 | { |
| 867 | fprintf(stderr, "could not open tty\n"); |
| 868 | d->dfout_C = fopen("/dev/stdout", "w"); |
| 869 | return false; |
| 870 | } |
| 871 | } |
| 872 | std::cin.tie(this); |
| 873 | clear(); |
| 874 | d->supported_terminal = !isUnsupportedTerm() && isatty(STDIN_FILENO); |
| 875 | // init the exit mechanism |
| 876 | if (pipe(d->exit_pipe) == -1) |
| 877 | ; |
| 878 | FD_ZERO(&d->descriptor_set); |
| 879 | FD_SET(STDIN_FILENO, &d->descriptor_set); |
| 880 | FD_SET(d->exit_pipe[0], &d->descriptor_set); |
| 881 | inited = true; |
| 882 | return true; |
| 883 | } |
| 884 | |
| 885 | bool Console::shutdown(void) |
| 886 | { |
nothing calls this directly
no test coverage detected