1827293 Members
3440 Online
109717 Solutions
New Discussion

Re: Use of special file

 
venkatesh_4
New Member

Use of special file

Hi all,
Tivoli software creates a special file in /tmp directory. It's a pipe. Can any one explain me how to create special files and what is the use of them.

Thanks

Venkat
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: Use of special file

Special files are created using the command "mknod". The type of file is decided based on the major number through the command "lsdev". For ex., for pipe 164. Pipe device files are used for interprocess communication. It's a very primitive way of IPC but there are other reasons to use the pipe special files. Pipe works exactly like a "pipe" for the message flow. Send through one and receive through the other.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Steven Gillard_2
Honored Contributor

Re: Use of special file

A named pipe or fifo file is created with the mkfifo(1) command, and is used for inter-process communication. A process reading from the pipe file can receive messages written by other processes.

Somebody else may be able to better explain exactly how Tivoli uses them.

Cheers,
Steve
A. Clay Stephenson
Acclaimed Contributor

Re: Use of special file

Sure, that is called a 'named pipe' and can be created as simply as 'mknod p /tmp/mypipe'.

For your purpose, it simply becomes a file that non-related (or related processes for that matter) can read from and write to.

e.g. Process 1: ls -l /etc > /tmp/mypipe
Process 2: myproc < /tmp/mypipe

Process 2 reads from the named pipe just as though it had been typed in from the keyboard i.e. the pipe became its stdin.

One way to think of named pipes is simply as a mailbox where processes can drop off and pick up data.
If it ain't broke, I can fix that.
Wodisch
Honored Contributor

Re: Use of special file

Hello Venkat,

on HP-UX (as on most UN*Xes) we have (based on the output of 'll'):
- files
d directories
p named pipes
b block devices (think of disks)
c character devices (every device else)
l symbolic links
s sockets

The types "b" and "c" can only be created by super-users, all the others can be created by ordinary users (with the proper commands, of course).

A file can be read as often as you want, but the contents of a pipe cann only be read once and are gone then!
Named pipes are useful to *connect* two processes of different users, since *anonymous pipes* (i.e. '|') can only connect two processes started by the same parent process and hence user.

HTH,
Wodisc
Deepak Extross
Honored Contributor

Re: Use of special file

To add to what the others have said, you can identify pipes by their long listing (ls -l).
The first character in the permissions will be 'p' for a pipe.
Also, 'file ' will return "fifo" if is a pipe.