Next: , Previous: Special FD, Up: Special Files



4.7.2 Special Files for Process-Related Information

gawk also provides special file names that give access to information about the running gawk process. Each of these “files” provides a single record of information. To read them more than once, they must first be closed with the close function (see Close Files And Pipes). The file names are:

/dev/pid
Reading this file returns the process ID of the current process, in decimal form, terminated with a newline.
/dev/ppid
Reading this file returns the parent process ID of the current process, in decimal form, terminated with a newline.
/dev/pgrpid
Reading this file returns the process group ID of the current process, in decimal form, terminated with a newline.
/dev/user
Reading this file returns a single record terminated with a newline. The fields are separated with spaces. The fields represent the following information:
$1
The return value of the getuid system call (the real user ID number).
$2
The return value of the geteuid system call (the effective user ID number).
$3
The return value of the getgid system call (the real group ID number).
$4
The return value of the getegid system call (the effective group ID number).

If there are any additional fields, they are the group IDs returned by the getgroups system call. (Multiple groups may not be supported on all systems.)

These special file names may be used on the command line as data files, as well as for I/O redirections within an awk program. They may not be used as source files with the -f option.

NOTE: The special files that provide process-related information are now considered obsolete and will disappear entirely in the next release of gawk. gawk prints a warning message every time you use one of these files. To obtain process-related information, use the PROCINFO array. See Auto-set.