STDOUT
if (ioctl(STDOUT, TIOCGETP, &old_settings) == -1)
if (ioctl(STDOUT, TCGETA, &old_settings) == -1)
if (tcgetattr(STDOUT, &old_settings) == -1)
if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1)
(void) ioctl(STDOUT, TIOCSETP, &new_settings);
(void) ioctl(STDOUT, TIOCLGET, &old_lword);
(void) ioctl(STDOUT, TIOCLSET, &new_lword);
if (ioctl(STDOUT, TCGETA, &old_settings) != -1)
(void) ioctl(STDOUT, TCSETA, &new_settings);
if (tcgetattr(STDOUT, &old_settings) != -1)
(void) tcsetattr(STDOUT, TCSADRAIN, &new_settings);
(void) ioctl(STDOUT, TIOCSETP, &old_settings);
(void) ioctl(STDOUT, TIOCLSET, &old_lword);
(void) ioctl(STDOUT, TCSETA, &old_settings);
(void) tcsetattr(STDOUT, TCSADRAIN, &old_settings);
(void) ioctl(STDOUT, TIOCSETP, &new_settings);
(void) ioctl(STDOUT, TIOCLSET, &new_lword);
(void) ioctl(STDOUT, TCSETA, &new_settings);
(void) tcsetattr(STDOUT, TCSADRAIN, &new_settings);
close(STDOUT); dup2(stdout_pipe[WRITE_PIPE], STDOUT);
close(STDERR); dup2(STDOUT, STDERR);
close(STDOUT); open(_PATH_DEVNULL, 1);