commit - ff553ea7e0fb7b9ca9834780057bdd0f709339f5
commit + f4086c716b2f27f2f0e34157dcd64960589a3c9f
blob - e0fcc1a64a5f6169ecb16f98c8a65b82b97bea52
blob + 51022b6090574aeb9224b976148c4f0a2979f53f
--- tog/tog.c
+++ tog/tog.c
init_mock_term(const char *test_script_path)
{
const struct got_error *err = NULL;
+ int in;
if (test_script_path == NULL || *test_script_path == '\0')
return got_error_msg(GOT_ERR_IO, "TOG_TEST_SCRIPT not defined");
/* test mode, we don't want any output */
tog_io.cout = fopen("/dev/null", "w+");
if (tog_io.cout == NULL) {
- err = got_error_from_errno("fopen: /dev/null");
+ err = got_error_from_errno2("fopen", "/dev/null");
goto done;
}
- tog_io.cin = fopen("/dev/tty", "r+");
+ in = dup(fileno(tog_io.cout));
+ if (in == -1) {
+ err = got_error_from_errno("dup");
+ goto done;
+ }
+ tog_io.cin = fdopen(in, "r");
if (tog_io.cin == NULL) {
- err = got_error_from_errno("fopen: /dev/tty");
+ err = got_error_from_errno("fdopen");
+ close(in);
goto done;
}