2009-09-10 13:58:49 +05:30
|
|
|
'\" -*- coding: UTF-8 -*-
|
|
|
|
.\" Copyright (C) 1998 Miquel van Smoorenburg.
|
|
|
|
.\"
|
|
|
|
.\" This program is free software; you can redistribute it and/or modify
|
|
|
|
.\" it under the terms of the GNU General Public License as published by
|
|
|
|
.\" the Free Software Foundation; either version 2 of the License, or
|
|
|
|
.\" (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" This program is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public License
|
|
|
|
.\" along with this program; if not, write to the Free Software
|
|
|
|
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
.\"
|
2022-02-16 02:31:41 +05:30
|
|
|
.TH PIDOF 8 "01 Sep 1998" "sysvinit " "Linux System Administrator's Manual"
|
2009-09-10 13:58:49 +05:30
|
|
|
.SH NAME
|
2021-12-28 01:44:42 +05:30
|
|
|
pidof - find the process ID of a running program
|
2009-09-10 13:58:49 +05:30
|
|
|
.SH SYNOPSIS
|
|
|
|
.B pidof
|
|
|
|
.RB [ \-s ]
|
|
|
|
.RB [ \-c ]
|
2010-02-23 22:21:18 +05:30
|
|
|
.RB [ \-n ]
|
2009-09-10 13:58:49 +05:30
|
|
|
.RB [ \-x ]
|
2019-07-05 06:30:47 +05:30
|
|
|
.RB [ \-z ]
|
2009-09-10 13:58:49 +05:30
|
|
|
.RB [ \-o
|
2018-11-11 06:57:11 +05:30
|
|
|
.IR omitpid[,omitpid...] ]
|
2009-09-10 13:58:49 +05:30
|
|
|
.RB [ \-o
|
2018-11-11 06:57:11 +05:30
|
|
|
.IR omitpid[,omitpid...]... ]
|
2019-03-20 22:16:36 +05:30
|
|
|
.RB [ \-d
|
|
|
|
.IR sep ]
|
2021-12-28 01:44:42 +05:30
|
|
|
.I program
|
|
|
|
.RI [ program... ]
|
2009-09-10 13:58:49 +05:30
|
|
|
.SH DESCRIPTION
|
2021-12-28 01:44:42 +05:30
|
|
|
.B pidof
|
2018-09-09 01:49:21 +05:30
|
|
|
finds the process id's (PIDs) of the named programs. It prints those
|
2009-09-10 13:58:49 +05:30
|
|
|
id's on the standard output. This program is on some systems used in
|
|
|
|
run-level change scripts, especially when the system has a
|
|
|
|
\fISystem-V\fP like \fIrc\fP structure. In that case these scripts are
|
2021-12-28 01:44:42 +05:30
|
|
|
located in \fI/etc/rc?.d\fP, where ? is the runlevel. If the system has
|
|
|
|
a \fBstart-stop-daemon\fP(8) program that should be used instead.
|
2009-09-10 13:58:49 +05:30
|
|
|
.SH OPTIONS
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-s\fP
|
2009-09-10 13:58:49 +05:30
|
|
|
Single shot - this instructs the program to only return one \fIpid\fP.
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-c\fP
|
2018-09-09 01:49:21 +05:30
|
|
|
Only return process PIDs that are running with the same root directory.
|
2009-09-10 13:58:49 +05:30
|
|
|
This option is ignored for non-root users, as they will be unable to check
|
|
|
|
the current root directory of processes they do not own.
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-n\fP
|
2010-02-23 22:21:18 +05:30
|
|
|
Avoid
|
|
|
|
.BR stat (2)
|
|
|
|
system function call on all binaries which are located on network
|
|
|
|
based file systems like
|
|
|
|
.BR NFS .
|
2018-11-11 06:57:11 +05:30
|
|
|
Instead of using this option the variable
|
2010-02-23 22:21:18 +05:30
|
|
|
.B PIDOF_NETFS
|
|
|
|
may be set and exported.
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-q\fP
|
2018-09-09 01:49:21 +05:30
|
|
|
Do not display matched PIDs to standard out. Simply exit with
|
|
|
|
a status of true or false to indicate whether a matching PID was found.
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-x\fP
|
2009-09-10 13:58:49 +05:30
|
|
|
Scripts too - this causes the program to also return process id's of
|
|
|
|
shells running the named scripts.
|
2021-12-28 01:44:42 +05:30
|
|
|
.IP \fB\-z\fP
|
2021-10-21 23:14:55 +05:30
|
|
|
Try to detect processes which are stuck in zombie (Z)
|
2019-07-05 06:30:47 +05:30
|
|
|
status. Usually these processes are skipped as trying to deal with them can cause
|
2021-10-21 23:14:55 +05:30
|
|
|
pidof or related tools to hang. Note: In the past pidof would ignore processes
|
2021-12-28 01:44:42 +05:30
|
|
|
in the uninterruptable state (D), unless the \fB-z\fP flag was specified. This is no
|
|
|
|
longer the case. The \fBpidof\fP program will find and report processes in the D state
|
|
|
|
whether \fB-z\fP is specified or not.
|
2019-03-20 22:16:36 +05:30
|
|
|
.IP "-d \fIsep\fP"
|
|
|
|
Tells \fIpidof\fP to use \fIsep\fP as an output separator if more than one PID
|
|
|
|
is shown. The default separator is a space.
|
2009-09-10 13:58:49 +05:30
|
|
|
.IP "-o \fIomitpid\fP"
|
|
|
|
Tells \fIpidof\fP to omit processes with that process id. The special
|
2021-12-28 01:44:42 +05:30
|
|
|
pid \fB%PPID\fP can be used to name the parent process of the \fBpidof\fP
|
2009-09-10 13:58:49 +05:30
|
|
|
program, in other words the calling shell or shell script.
|
|
|
|
.SH "EXIT STATUS"
|
|
|
|
.TP
|
|
|
|
.B 0
|
|
|
|
At least one program was found with the requested name.
|
|
|
|
.TP
|
|
|
|
.B 1
|
|
|
|
No program was found with the requested name.
|
|
|
|
.SH NOTES
|
2021-12-28 01:44:42 +05:30
|
|
|
\fIpidof\fP is actually the same program as \fBkillall5\fP(8);
|
2009-09-10 13:58:49 +05:30
|
|
|
the program behaves according to the name under which it is called.
|
|
|
|
.PP
|
2021-12-28 01:44:42 +05:30
|
|
|
When \fBpidof\fP is invoked with a full pathname to the program it
|
2009-09-10 13:58:49 +05:30
|
|
|
should find the pid of, it is reasonably safe. Otherwise it is possible
|
2018-09-09 01:49:21 +05:30
|
|
|
that it returns PIDs of running programs that happen to have the same name
|
2018-11-11 06:57:11 +05:30
|
|
|
as the program you're after but are actually other programs. Note
|
2010-03-23 20:07:01 +05:30
|
|
|
that the executable name of running processes is calculated with
|
|
|
|
.BR readlink (2),
|
2023-03-29 19:04:45 +05:30
|
|
|
so symbolic links to executables will also match.
|
2019-05-26 00:11:57 +05:30
|
|
|
.PP
|
|
|
|
Zombie processes or processes in disk sleep (states Z and D, respectively)
|
|
|
|
are ignored, as attempts to access the stats of these will sometimes fail.
|
2021-12-28 01:44:42 +05:30
|
|
|
The \fB\-z\fP flag (see above) tells \fBpidof\fP to try to detect these sleeping and zombie
|
2019-07-05 06:30:47 +05:30
|
|
|
processes, at the risk of failing or hanging.
|
2010-03-23 20:07:01 +05:30
|
|
|
|
2009-09-10 13:58:49 +05:30
|
|
|
.SH SEE ALSO
|
|
|
|
.BR shutdown (8),
|
|
|
|
.BR init (8),
|
|
|
|
.BR halt (8),
|
|
|
|
.BR reboot (8),
|
|
|
|
.BR killall5 (8)
|
|
|
|
.SH AUTHOR
|
2021-12-28 01:44:42 +05:30
|
|
|
.MT miquels@\:cistron\:.nl
|
|
|
|
Miquel van Smoorenburg
|
|
|
|
.ME
|