coreutils tee source code closes standard input and output upon exit:
int
main (int argc, char **argv)
{
atexit (close_stdout);
<......>
ok = tee_files (argc - optind, &argv[optind]);
if (close (STDIN_FILENO) != 0)
die (EXIT_FAILURE, errno, "%s", _("standard input"));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
I wonder if it is necessary to do that as when the tee program terminates, STDIN and STDOUT are automatically closed by process management.
Is this just a good coding practice or is there a use case?