Print this page
12046 Provide /proc/<PID>/fdinfo/
   1 .\" Copyright 1989 AT&T
   2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   3 .\" Copyright 2019, Joyent, Inc.

   4 .\"
   5 .\" The contents of this file are subject to the terms of the
   6 .\" Common Development and Distribution License (the "License").
   7 .\" You may not use this file except in compliance with the License.
   8 .\"
   9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 .\" or http://www.opensolaris.org/os/licensing.
  11 .\" See the License for the specific language governing permissions
  12 .\" and limitations under the License.
  13 .\"
  14 .\" When distributing Covered Code, include this CDDL HEADER in each
  15 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 .\" If applicable, add the following below this CDDL HEADER, with the
  17 .\" fields enclosed by brackets "[]" replaced with your own identifying
  18 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  19 .\"
  20 .Dd January 11, 2019
  21 .Dt PROC 4
  22 .Os
  23 .Sh NAME
  24 .Nm proc
  25 .Nd /proc, the process file system
  26 .Sh DESCRIPTION
  27 .Pa /proc
  28 is a file system that provides access to the state of each process
  29 and light-weight process (lwp) in the system.
  30 The name of each entry in the
  31 .Pa /proc
  32 directory is a decimal number corresponding to a process-ID.
  33 These entries are themselves subdirectories.
  34 Access to process state is provided by additional files contained within each
  35 subdirectory; the hierarchy is described more completely below.
  36 In this document,
  37 .Dq Pa /proc file
  38 refers to a non-directory file within the hierarchy rooted at
  39 .Pa /proc .
  40 The owner of each


1365 can differ from the system root directory if the process or one of its
1366 ancestors executed
1367 .Xr chroot 2
1368 as super user.
1369 It has the same semantics as
1370 .Pa /proc/ Ns Em pid Ns Pa /cwd .
1371 .Ss fd
1372 A directory containing references to the open files of the process.
1373 Each entry is a decimal number corresponding to an open file descriptor in the
1374 process.
1375 .Pp
1376 If an entry refers to a regular file, it can be opened with normal file system
1377 semantics but, to ensure that the controlling process cannot gain greater
1378 access than the controlled process, with no file access modes other than its
1379 read/write open modes in the controlled process.
1380 If an entry refers to a directory, it can be accessed with the same semantics
1381 as
1382 .Pa /proc/ Ns Em pid Ns Pa /cwd .
1383 An attempt to open any other type of entry fails with
1384 .Er EACCES .





































































































































1385 .Ss object
1386 A directory containing read-only files with names corresponding to the
1387 .Sy pr_mapname
1388 entries in the
1389 .Sy map
1390 and
1391 .Sy pagedata
1392 files.
1393 Opening such a file yields a file descriptor for the underlying mapped file
1394 associated with an address-space mapping in the process.
1395 The file name
1396 .Pa a.out
1397 appears in the directory as an alias for the process's executable file.
1398 .Pp
1399 The
1400 .Pa object
1401 directory makes it possible for a controlling process to gain
1402 access to the object file and any shared libraries (and consequently the symbol
1403 tables) without having to know the actual path names of the executable files.
1404 .Ss path


   1 .\" Copyright 1989 AT&T
   2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   3 .\" Copyright 2019, Joyent, Inc.
   4 .\" Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
   5 .\"
   6 .\" The contents of this file are subject to the terms of the
   7 .\" Common Development and Distribution License (the "License").
   8 .\" You may not use this file except in compliance with the License.
   9 .\"
  10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 .\" or http://www.opensolaris.org/os/licensing.
  12 .\" See the License for the specific language governing permissions
  13 .\" and limitations under the License.
  14 .\"
  15 .\" When distributing Covered Code, include this CDDL HEADER in each
  16 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 .\" If applicable, add the following below this CDDL HEADER, with the
  18 .\" fields enclosed by brackets "[]" replaced with your own identifying
  19 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  20 .\"
  21 .Dd December 3, 2019
  22 .Dt PROC 4
  23 .Os
  24 .Sh NAME
  25 .Nm proc
  26 .Nd /proc, the process file system
  27 .Sh DESCRIPTION
  28 .Pa /proc
  29 is a file system that provides access to the state of each process
  30 and light-weight process (lwp) in the system.
  31 The name of each entry in the
  32 .Pa /proc
  33 directory is a decimal number corresponding to a process-ID.
  34 These entries are themselves subdirectories.
  35 Access to process state is provided by additional files contained within each
  36 subdirectory; the hierarchy is described more completely below.
  37 In this document,
  38 .Dq Pa /proc file
  39 refers to a non-directory file within the hierarchy rooted at
  40 .Pa /proc .
  41 The owner of each


1366 can differ from the system root directory if the process or one of its
1367 ancestors executed
1368 .Xr chroot 2
1369 as super user.
1370 It has the same semantics as
1371 .Pa /proc/ Ns Em pid Ns Pa /cwd .
1372 .Ss fd
1373 A directory containing references to the open files of the process.
1374 Each entry is a decimal number corresponding to an open file descriptor in the
1375 process.
1376 .Pp
1377 If an entry refers to a regular file, it can be opened with normal file system
1378 semantics but, to ensure that the controlling process cannot gain greater
1379 access than the controlled process, with no file access modes other than its
1380 read/write open modes in the controlled process.
1381 If an entry refers to a directory, it can be accessed with the same semantics
1382 as
1383 .Pa /proc/ Ns Em pid Ns Pa /cwd .
1384 An attempt to open any other type of entry fails with
1385 .Er EACCES .
1386 .Ss fdinfo
1387 A directory containing information about each of the process's open files.
1388 Each entry is a decimal number corresponding to an open file descriptor in the
1389 process.
1390 Each file contains a
1391 .Sy prfdinfov2_t
1392 structure as follows:
1393 .Bd -literal -offset 2
1394 typedef struct prfdinfov2 {
1395     int     pr_fd;          /* file descriptor number */
1396     mode_t  pr_mode;        /* (see st_mode in stat(2)) */
1397     uint64_t pr_ino;        /* inode number */
1398     uint64_t pr_size;       /* file size */
1399     int64_t pr_offset;      /* current offset of file descriptor */
1400     uid_t   pr_uid;         /* owner's user id */
1401     gid_t   pr_gid;         /* owner's group id */
1402     major_t pr_major;       /* major number of device containing file */
1403     minor_t pr_minor;       /* minor number of device containing file */
1404     major_t pr_rmajor;      /* major number (if special file) */
1405     minor_t pr_rminor;      /* minor number (if special file) */
1406     int     pr_fileflags;   /* (see F_GETXFL in fcntl(2)) */
1407     int     pr_fdflags;     /* (see F_GETFD in fcntl(2)) */
1408     short   pr_locktype;    /* (see F_GETLK in fcntl(2)) */
1409     pid_t   pr_lockpid;     /* process holding file lock (see F_GETLK) */
1410     int     pr_locksysid;   /* sysid of locking process (see F_GETLK) */
1411     pid_t   pr_peerpid;     /* peer process (socket, door) */
1412     int     pr_filler[25];  /* reserved for future use */
1413     char    pr_peername[PRFNSZ]; /* peer process name */
1414 #if __STDC_VERSION__ >= 199901L
1415     char    pr_misc[];      /* self describing structures */
1416 #else
1417     char    pr_misc[1];
1418 #endif
1419 } prfdinfov2_t;
1420 .Ed
1421 .Pp
1422 The
1423 .Sy pr_misc
1424 element points to a list of additional miscellaneous data items, each of which
1425 has a header of type
1426 .Sy pr_misc_header_t
1427 specifying the size and type, and some data which immediately follow
1428 the header.
1429 .Bd -literal -offset 2
1430 typedef struct pr_misc_header {
1431     uint_t          pr_misc_size;
1432     uint_t          pr_misc_type;
1433 } pr_misc_header_t;
1434 .Ed
1435 .Pp
1436 The
1437 .Sy pr_misc_size
1438 field is the sum of the sizes of the header and the associated data.
1439 The end of the list is indicated by a header with a zero size.
1440 .Pp
1441 The following miscellaneous data types can be present:
1442 .Bl -tag -width "PR_SOCKOPT_TCP_CONGESTION" -offset left
1443 .It Sy PR_PATHNAME
1444 The file descriptor's path in the filesystem.
1445 This is a sequence of characters of the length indicated by
1446 .Sy pr_misc_size
1447 and it not guaranteed to be null-terminated.
1448 .It Sy PR_SOCKETNAME
1449 A
1450 .Sy sockaddr
1451 structure representing the local socket name for this file descriptor, as
1452 would be returned by calling
1453 .Fn getsockname
1454 within the process.
1455 .It Sy PR_PEERSOCKNAME
1456 A
1457 .Sy sockaddr
1458 structure representing the peer socket name for this file desciptor, as
1459 would be returned by calling
1460 .Fn getpeername
1461 within the process.
1462 .It Sy PR_SOCKOPTS_BOOL_OPTS
1463 An unsigned integer which has bits set corresponding to options which are
1464 set on the underlying socket.
1465 The following bits may be set:
1466 .Bl -tag -width "PR_SO_PASSIVE_CONNECT"
1467 .It Sy PR_SO_DEBUG
1468 .It Sy PR_SO_REUSEADDR
1469 .It Sy PR_SO_REUSEPORT
1470 .It Sy PR_SO_KEEPALIVE
1471 .It Sy PR_SO_DONTROUTE
1472 .It Sy PR_SO_BROADCAST
1473 .It Sy PR_SO_OOBINLINE
1474 .It Sy PR_SO_DGRAM_ERRIND
1475 .It Sy PR_SO_ALLZONES
1476 .It Sy PR_SO_MAC_EXEMPT
1477 .It Sy PR_SO_EXCLBIND
1478 .It Sy PR_SO_PASSIVE_CONNECT
1479 .It Sy PR_SO_ACCEPTCONN
1480 .It Sy PR_UDP_NAT_T_ENDPOINT
1481 .It Sy PR_SO_VRRP
1482 .It Sy PR_SO_MAC_IMPLICIT
1483 .El
1484 .It Sy PR_SOCKOPT_LINGER
1485 A
1486 .Sy struct linger
1487 as would be returned by calling
1488 .Fn getsockopt SO_LINGER
1489 within the process.
1490 .It Sy PR_SOCKOPT_SNDBUF
1491 The data that would be returned by calling
1492 .Fn getsockopt SO_SNDBUF
1493 within the process.
1494 .It Sy PR_SOCKOPT_RCVBUF
1495 The data that would be returned by calling
1496 .Fn getsockopt SO_RCVBUF
1497 within the process.
1498 .It Sy PR_SOCKOPT_IP_NEXTHOP
1499 The data that would be returned by calling
1500 .Fn getsockopt IPPROTO_IP IP_NEXTHOP
1501 within the process.
1502 .It Sy PR_SOCKOPT_IPV6_NEXTHOP
1503 The data that would be returned by calling
1504 .Fn getsockopt IPPROTO_IPV6 IPV6_NEXTHOP
1505 within the process.
1506 .It Sy PR_SOCKOPT_TYPE
1507 The data that would be returned by calling
1508 .Fn getsockopt SO_TYPE
1509 within the process.
1510 .It Sy PR_SOCKOPT_TCP_CONGESTION
1511 For TCP sockets, the data that would be returned by calling
1512 .Fn getsockopt IPPROTO_TCP TCP_CONGESTION
1513 within the process.
1514 This is a character array containing the name of the congestion algorithm
1515 in use for the socket.
1516 .It Sy PR_SOCKFILTERS_PRIV
1517 Private data relating to any socket filters pushed on this descriptor.
1518 .El
1519 .Ss object
1520 A directory containing read-only files with names corresponding to the
1521 .Sy pr_mapname
1522 entries in the
1523 .Sy map
1524 and
1525 .Sy pagedata
1526 files.
1527 Opening such a file yields a file descriptor for the underlying mapped file
1528 associated with an address-space mapping in the process.
1529 The file name
1530 .Pa a.out
1531 appears in the directory as an alias for the process's executable file.
1532 .Pp
1533 The
1534 .Pa object
1535 directory makes it possible for a controlling process to gain
1536 access to the object file and any shared libraries (and consequently the symbol
1537 tables) without having to know the actual path names of the executable files.
1538 .Ss path