Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a C++ application and need to work with process substitution in the Bash shell.

I'm trying to find a way to validate the paths passed as arguments to my program, some of which point to FIFO files created by process substitution.

Is there a shell (or C++) way that I can check if the system creates these files in /dev/fd or if they are created somewhere else?

share|improve this question
up vote 0 down vote accepted

The short answer is that you cannot do this. Just because a directory is where bash defaults to putting fifo paths, doesn't mean that a particular fifo in that directory was created by bash, or that it was passed by bash as an argument to your command.

Take a look at the bigger picture of your problem. What are you REALLY trying to solve?

If you're trying to solve, "the output of my program must always be piped into another program," then don't require the user to use bash's obscure process substitution. What if the default shell on their system is zsh? Bourne shell? Korn shell?

Instead, have your program create a pipe, fork, and exec the other program.

So, what are you really trying to do? What happens if you, God forbid, write your output to a file the user of your program passed, instead of to a fifo created by bash?

share|improve this answer
I agree, this requirement is a bit obscure! However unfortunately I can't change it as the application is a software simulator that emulates the behaviour of another application that runs embedded on some hardware - the application it is emulating wasn't written by me and I can't change it's argument structure. Since the use cases for such a simulator are pretty limited, it's unlikely it will present a problem, I just wondered if there was an easy way to check (bash config file or something). Thanks! – Earl Sven Aug 17 '11 at 7:20

Use the -p option to test if a file is a pipe:

if [ -p "$file" ]
    echo "$file is a pipe"


$ <(echo hello)
/dev/fd/63 is a pipe
share|improve this answer
Thanks, this might be useful to construct a solution, however it doesn't tell me where these files are created by default (/dev/fd on most systems). Is there an environment variable or something that I could check to see what path this is? – Earl Sven Aug 16 '11 at 10:07
why? You shouldn't need to know where they are created. – dogbane Aug 16 '11 at 10:38
The reason I need to know is to validate paths passed as an argument to my application. Essentially what I call is myProg -fifopaths >(/run/some/application) what my program sees passed as the arguments to its main is /path/to/myProg -fifopaths /dev/fd/63 etc. I need to validate that any paths passed to my program are in fact in /dev/fd to be sure they are paths to a FIFO. The problem arises that if my program is executed on System-X where FIFO paths are not in /dev/fd, I need to know where these FIFO paths are supposed to be on System-X in order to validate the arguments. – Earl Sven Aug 16 '11 at 12:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.