Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
Copyright 2019 Joyent, Inc.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
/usr/bin/ptree [-a] [-c] [-g] [-w] [-s svc] [-z zone] [pid | user]...
All. Print all processes, including children of process 0.
Contracts. Print process contract memberships and their associated SMF FMRIs, in addition to parent-child relationships. See process(5). This option implies the -a option.
Use line drawing characters. If the current locale is a UTF-8 locale, the UTF-8 line drawing characters are used, otherwise ASCII line drawing characters are used.
Print only processes with an SMF service FMRI matching the argument. The FMRI may be in truncated form (such as 'console-login'). This includes child processes even if they are not members of the service contract. See process(5).
Allow output lines to wrap. Normally output lines are truncated to the current width of the terminal window.
Zones. Print only processes in the specified zone. Each zone ID can be specified as either a zone name or a numerical zone ID. This option is only useful when executed in the global zone.
Process-id or a list of process-ids. ptree also accepts /proc/nnn as a process-id, so the shell expansion /proc/* can be used to specify all processes in the system.
Username or list of usernames. Processes whose effective user IDs match those given are displayed.
The following example prints the process tree (including children of process 0) for processes which match the command name ssh:
$ ptree -a `pgrep ssh` 1 /sbin/init 100909 /usr/lib/ssh/sshd 569150 /usr/lib/ssh/sshd 569157 /usr/lib/ssh/sshd 569159 -ksh 569171 bash 569173 /bin/ksh 569193 bashExample 2
The following example prints the process tree (including children of process 0) for processes which match the command name ssh with ASCII line drawing characters:
$ ptree -ag `pgrep ssh` 1 /sbin/init `-100909 /usr/lib/ssh/sshd `-569150 /usr/lib/ssh/sshd `-569157 /usr/lib/ssh/sshd `-569159 -ksh `-569171 bash `-569173 /bin/ksh `-569193 bash
Successful operation.
An error has occurred.
process files
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability See below. |
The human readable output is Unstable. The options are Evolving.