sysvinit/man/pidof.8

96 lines
3.3 KiB
Groff
Raw Normal View History

'\" -*- 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
.\"
.TH PIDOF 8 "01 Sep 1998" "" "Linux System Administrator's Manual"
.SH NAME
pidof -- find the process ID of a running program.
.SH SYNOPSIS
.B pidof
.RB [ \-s ]
.RB [ \-c ]
.RB [ \-n ]
.RB [ \-x ]
.RB [ \-o
.IR omitpid[,omitpid..] ]
.RB [ \-o
.IR omitpid[,omitpid..].. ]
.B program
.RB [ program.. ]
.SH DESCRIPTION
.B Pidof
finds the process id's (PIDs) of the named programs. It prints those
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
located in /etc/rc?.d, where ? is the runlevel. If the system has
a
.B start-stop-daemon
(8) program that should be used instead.
.SH OPTIONS
.IP \-s
Single shot - this instructs the program to only return one \fIpid\fP.
.IP \-c
Only return process PIDs that are running with the same root directory.
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.
.IP \-n
Avoid
.BR stat (2)
system function call on all binaries which are located on network
based file systems like
.BR NFS .
Instead of using this option the the variable
.B PIDOF_NETFS
may be set and exported.
.IP \-q
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.
.IP \-x
Scripts too - this causes the program to also return process id's of
shells running the named scripts.
.IP "-o \fIomitpid\fP"
Tells \fIpidof\fP to omit processes with that process id. The special
pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
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
\fIpidof\fP is actually the same program as \fIkillall5\fP;
the program behaves according to the name under which it is called.
.PP
When \fIpidof\fP is invoked with a full pathname to the program it
should find the pid of, it is reasonably safe. Otherwise it is possible
that it returns PIDs of running programs that happen to have the same name
as the program you're after but are actually other programs. Note that
that the executable name of running processes is calculated with
.BR readlink (2),
so symbolic links to executables will also match.
.SH SEE ALSO
.BR shutdown (8),
.BR init (8),
.BR halt (8),
.BR reboot (8),
.BR killall5 (8)
.SH AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl