where is the location of stdin, stdout, stderr file descriptor in AIX(unix)

25,613

Solution 1

The question is based on a misconception about the generality of proc filesystems. Systems which implement this (such as Solaris and Linux) have special devices which may be used for scripting, including /dev/fd followed by a file descriptor (number).

With Solaris (as well as some BSDs such as MacOS, FreeBSD), /dev/fd is a virtual folder under /dev, while Linux uses a symbolic link to /proc into a (virtual) folder matching your process id. There are no standards for proc filesystems, and details will differ.

The BSDs do not use identical schemes: Solaris, MacOS and FreeBSD use symbolic links for the stdin, stdout, stderr into this /dev/fd folder, while NetBSD and OpenBSD do this using a device node (with the same major/minor numbers). But they are similar. The /dev/fd is separate from /proc (which Solaris supports, unlike the BSDs).

Checking AIX 5.3 and 7.1 systems, they do implement a proc filesystem, but have no /dev/fd. However, they do have a virtual filesystem /proc, under which you can find your current process-id, and under that is an fd folder with file descriptors.

Conventionally, file descriptors are initialized 0, 1, 2 for stdin, stdout, stderr respectively.

Further reading:

Contains files for all open file descriptors of the process. Each entry is a decimal number corresponding to an open file descriptor in the process. If an entity refers to a regular file, it can be opened with normal file semantics. To ensure that the controlling process cannot gain greater access, there are no file access modes other than its own read/write open modes in the controlled process. Directories will be displayed as links. An attempt to open any other type of entry will fail (hence it will display 0 permission when listed).

The /dev/fd feature was developed by Tom Duff and appeared in the 8th Edition of the Research Unix System. It is supported by SVR4 and 4.3+BSD. It is not part of POSIX.1.

Solution 2

Those are artificial file descriptors and are certainly not needed for processing, which explains that they were not there historically and still absent on some systems.

The shell handles these standard file descriptors based on your TTY. When the shell is started, it calls isatty(), and if it is (a TTY) it opens the standard file descriptors on it automatically.

Share:
25,613

Related videos on Youtube

asleea
Author by

asleea

Updated on September 18, 2022

Comments

  • asleea
    asleea over 1 year

    In my Linux environment, the file descriptors are located on /dev/fd.

    Where is the location of stdin, stdout, stderr file descriptor in AIX(unix).

    I couldn't find them.