commit f4086c716b2f27f2f0e34157dcd64960589a3c9f from: Omar Polo via: Thomas Adam date: Sat Apr 22 18:10:32 2023 UTC tog: don't open /dev/tty during regress as it might not be there (for e.g. if ran under cron). Reuse instead /dev/null since it's not expected to get input from stdin. ok jamsek commit - ff553ea7e0fb7b9ca9834780057bdd0f709339f5 commit + f4086c716b2f27f2f0e34157dcd64960589a3c9f blob - e0fcc1a64a5f6169ecb16f98c8a65b82b97bea52 blob + 51022b6090574aeb9224b976148c4f0a2979f53f --- tog/tog.c +++ tog/tog.c @@ -4190,6 +4190,7 @@ static const struct got_error * 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"); @@ -4204,13 +4205,19 @@ init_mock_term(const char *test_script_path) /* 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; }