There are several types of special files:
- A character
special file is a file that provides access to an input/output
device. Examples of character special files are: a terminal file,
a NULL file, a file descriptor file, or a system console file. Each
character special file has a device major number, which identifies
the device type, and a device minor number, which identifies a specific
device of a given device type. Character special files are customarily
defined in /dev; these files are defined with the mknod command.
You must have UID(0) to create a character special file. The best
way to obtain UID(0) is to be defined to BPX.SUPERUSER FACILITY class.
Then issue the su command to switch to UID(0) before issuing
the mknod command.
You cannot share character
special files in read/write mode among systems participating in a
shared file system in a sysplex.
- A pipe is a way to communicate in first-in-first-out (FIFO)
order from one or more processes to one or more processes. Pipes are
treated as though they were files.
Figure 1 shows how a pipe works.
Figure 1. How a pipe works
A pipe sends
data from one process to another or back to itself. By forking processes,
a pipe can be shared by a number of processes; for example, written
to by three processes and read by seven.
A program creates a
pipe with a pipe() function. The pipe vanishes when the last process
closes it. A pipe does not have a name in the file system; a pipe
is also called an unnamed pipe.
- A FIFO special file sends data from one process to another
so that the receiving process reads the data first-in-first-out (FIFO).
A FIFO special file is also called a named pipe, or a FIFO.
A FIFO special file can also be shared by a number of processes that
were not created by forks. A FIFO special file can be written into
and read by the same process using multiple threads.
FIFO special
files can be shared between systems that use shared file systems.
For more information about shared file systems, see Sharing file systems in a sysplex.
A program creates a FIFO special
file with a mkfifo command or a mkfifo() function.
The name is maintained in the file system until the named pipe is
deleted by an rm command or an unlink() function.
- A UNIX domain socket
address file represents socket addresses in the UNIX domain.
These files cannot
be shared in read/write mode among systems participating in a shared
file system in a sysplex.
To prepare for using AF_UNIX (local)
sockets, the AF_UNIX physical file system (PFS) creates a socket address
file in the file hierarchy during the bind() function call. The files
are defined as specified by the program that calls bind() and are
typically in the user's home directory, the root directory, or in /tmp.
Because
they are part of the file system, be careful not to delete any of
these socket address files by accident. If you do delete them, programs
will not be able to connect to or send datagrams to the program that
created the file.
Pipes and FIFO special files are created by programs and users;
character special files are typically created by the system programmer.