Search code examples
pythonpipe

Check if file is a named pipe (fifo) in python?


I communicate with a named pipe, but I would like to check if it really is a named pipe BEFORE opening it.

I check in Google but there is nothing, os.path.isfile() returns False, and I really need to check it.


Solution

  • You can try:

     import stat, os
    
     stat.S_ISFIFO(os.stat(path).st_mode)
    

    docs