Commit bb369dc6 authored by Richard M. Stallman's avatar Richard M. Stallman

(USG5 or BSD_SYSTEM or LINUX): Include fcntl.h.

(Ffile_readable_p): Return immediately if stat fails.
Call S_ISFIFO correctly.
parent a14bf24d
...@@ -20,6 +20,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -20,6 +20,10 @@ Boston, MA 02111-1307, USA. */
#include <config.h> #include <config.h>
#if defined (USG5) || defined (BSD_SYSTEM) || defined (LINUX)
#include <fcntl.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -31,6 +35,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -31,6 +35,10 @@ Boston, MA 02111-1307, USA. */
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif #endif
#if !defined (S_ISFIFO) && defined (S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined (S_ISREG) && defined (S_IFREG) #if !defined (S_ISREG) && defined (S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif #endif
...@@ -2616,6 +2624,8 @@ See also `file-exists-p' and `file-attributes'.") ...@@ -2616,6 +2624,8 @@ See also `file-exists-p' and `file-attributes'.")
Lisp_Object absname; Lisp_Object absname;
Lisp_Object handler; Lisp_Object handler;
int desc; int desc;
int flags;
struct stat statbuf;
CHECK_STRING (filename, 0); CHECK_STRING (filename, 0);
absname = Fexpand_file_name (filename, Qnil); absname = Fexpand_file_name (filename, Qnil);
...@@ -2632,7 +2642,18 @@ See also `file-exists-p' and `file-attributes'.") ...@@ -2632,7 +2642,18 @@ See also `file-exists-p' and `file-attributes'.")
return Qt; return Qt;
return Qnil; return Qnil;
#else /* not DOS_NT */ #else /* not DOS_NT */
desc = open (XSTRING (absname)->data, O_RDONLY); flags = O_RDONLY;
#if defined (S_ISFIFO) && defined (O_NONBLOCK)
/* Opening a fifo without O_NONBLOCK can wait.
We don't want to wait. But we don't want to mess wth O_NONBLOCK
except in the case of a fifo, on a system which handles it. */
desc = stat (XSTRING (absname)->data, &statbuf);
if (desc < 0)
return Qnil;
if (S_ISFIFO (statbuf.st_mode))
flags |= O_NONBLOCK;
#endif
desc = open (XSTRING (absname)->data, flags);
if (desc < 0) if (desc < 0)
return Qnil; return Qnil;
close (desc); close (desc);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment