# HG changeset patch # User reimar # Date 1287305920 0 # Node ID 27f6b9927eec71228b65b3cb807ba4aac54ca695 # Parent 666880b36b8b5a7b5b5c5a9f25a943d2d8ac2311 Do not fail opening a -input file= file just because stat failed, but try to call "open" in any case. diff -r 666880b36b8b -r 27f6b9927eec input/input.c --- a/input/input.c Sun Oct 17 08:49:02 2010 +0000 +++ b/input/input.c Sun Oct 17 08:58:40 2010 +0000 @@ -1786,15 +1786,17 @@ if(in_file) { struct stat st; - if(stat(in_file,&st)) - mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantStatFile,in_file,strerror(errno)); - else { - in_file_fd = open(in_file,S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY); + // use RDWR for FIFOs to ensure they stay open over multiple accesses + int mode = O_RDWR; + // e.g. on Windows stat may fail for named pipes, trying to open read-only + // is a safe choice. + if (stat(in_file,&st) || !S_ISFIFO(st.st_mode)) + mode = O_RDONLY; + in_file_fd = open(in_file, mode); if(in_file_fd >= 0) mp_input_add_cmd_fd(in_file_fd,1,NULL,(mp_close_func_t)close); else mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantOpenFile,in_file,strerror(errno)); - } } }