1 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
   2 .\" Copyright 2019, Joyent, Inc.
   3 .\"
   4 .\" The contents of this file are subject to the terms of the
   5 .\" Common Development and Distribution License (the "License").
   6 .\" You may not use this file except in compliance with the License.
   7 .\"
   8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 .\" or http://www.opensolaris.org/os/licensing.
  10 .\" See the License for the specific language governing permissions
  11 .\" and limitations under the License.
  12 .\"
  13 .\" When distributing Covered Code, include this CDDL HEADER in each
  14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 .\" If applicable, add the following below this CDDL HEADER, with the
  16 .\" fields enclosed by brackets "[]" replaced with your own identifying
  17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  18 .\"
  19 .Dd January 12, 2019
  20 .Dt PTREE 1
  21 .Os
  22 .Sh NAME
  23 .Nm ptree
  24 .Nd print process trees
  25 .Sh SYNOPSIS
  26 .Nm
  27 .Op Fl a
  28 .Op Fl c
  29 .Op Fl z Ar zone
  30 .Oo Ar pid | Ar user Oc Ns ...
  31 .Sh DESCRIPTION
  32 The
  33 .Nm
  34 utility prints the process trees containing the specified
  35 .Ar pid Ns s
  36 or
  37 .Ar user Ns s ,
  38 with child processes indented from their respective parent processes.
  39 An argument of all digits is taken to be a process-ID,
  40 otherwise it is assumed to be a user login name.
  41 The default is all processes.
  42 .Sh OPTIONS
  43 The following options are supported:
  44 .Bl -tag -width "-z zone"
  45 .It Fl a
  46 All.
  47 Print all processes, including children of process 0.
  48 .It Fl c
  49 Contracts.
  50 Print process contract memberships in addition to parent-child relationships.
  51 See
  52 .Xr process 4 .
  53 This option implies the
  54 .Fl a
  55 option.
  56 .It Fl z Ar zone
  57 Zones.
  58 Print only processes in the specified
  59 .Ar zone .
  60 Each zone
  61 .Sy ID
  62 can be specified as either a zone name or a numerical zone
  63 .Sy ID .
  64 .Pp
  65 This option is only useful when executed in the global zone.
  66 .El
  67 .Sh OPERANDS
  68 The following operands are supported:
  69 .Bl -tag -width "user"
  70 .It Ar pid
  71 Process-id or a list of process-ids.
  72 .Nm
  73 also accepts
  74 .Pa /proc/ Ns Em nnn
  75 as a process-id, so the shell expansion
  76 .Pa /proc/*
  77 can be used to specify all processes in the system.
  78 .It Ar user
  79 Username or list of usernames.
  80 Processes whose effective user IDs match those
  81 given are displayed.
  82 .El
  83 .Sh FILES
  84 .Bl -tag -width Pa
  85 .It Pa /proc/*
  86 process files
  87 .El
  88 .Sh EXIT STATUS
  89 .Ex -std
  90 .Sh EXAMPLES
  91 .Bl -inset
  92 .It Sy Example 1
  93 Using ptree
  94 .Pp
  95 The following example prints the process tree (including children of process 0)
  96 for processes which match the command name
  97 .Sy ssh :
  98 .Bd -literal -offset 2n
  99 $ ptree -a `pgrep ssh`
 100         1     /sbin/init
 101           100909 /usr/lib/ssh/sshd
 102             569150 /usr/lib/ssh/sshd
 103               569157 /usr/lib/ssh/sshd
 104                 569159 -ksh
 105                   569171 bash
 106                     569173 /bin/ksh
 107                       569193 bash
 108 .Ed
 109 .El
 110 .Sh INTERFACE STABILITY
 111 Not-an-Interface
 112 .Sh SEE ALSO
 113 .Xr gcore 1 ,
 114 .Xr ldd 1 ,
 115 .Xr pargs 1 ,
 116 .Xr pgrep 1 ,
 117 .Xr pkill 1 ,
 118 .Xr plimit 1 ,
 119 .Xr pmap 1 ,
 120 .Xr ppgsz 1 ,
 121 .Xr preap 1 ,
 122 .Xr proc 1 ,
 123 .Xr ps 1 ,
 124 .Xr pwd 1 ,
 125 .Xr rlogin 1 ,
 126 .Xr time 1 ,
 127 .Xr truss 1 ,
 128 .Xr wait 1 ,
 129 .Xr fcntl 2 ,
 130 .Xr fstat 2 ,
 131 .Xr setuid 2 ,
 132 .Xr dlopen 3C ,
 133 .Xr signal.h 3HEAD ,
 134 .Xr core 4 ,
 135 .Xr proc 4 ,
 136 .Xr process 4 ,
 137 .Xr attributes 5 ,
 138 .Xr zones 5