X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=mdp.c;h=3d38e3fffeb61a21188293fd4fcc9f836c70b558;hb=0435bbf91540e1ef2ec232fc7aa891b79e366c99;hp=3bf1bd20f696cede99ce06edf29c2d36020a6496;hpb=cf34c7f44f300adb3ccea39dfcd676adfcd0cd5f;p=smdp.git diff --git a/mdp.c b/mdp.c index 3bf1bd2..3d38e3f 100644 --- a/mdp.c +++ b/mdp.c @@ -109,8 +109,13 @@ int main(int argc, char *argv[]) { fclose(input); // replace stdin with current tty if input was a pipe - if(input == stdin) - freopen("/dev/tty", "rw", stdin); + if(input == stdin) { + input = freopen("/dev/tty", "rw", stdin); + if(!input) { + fprintf(stderr, "%s: %s: %s\n", argv[0], "/dev/tty", strerror(errno)); + exit(EXIT_FAILURE); + } + } if(debug > 0) { markdown_debug(deck, debug);