171 lines
4.7 KiB
HTML
171 lines
4.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of PIDOF</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>PIDOF</H1>
|
|
Section: Linux System Administrator's Manual (8)<BR>Updated: 01 Sep 1998<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
pidof -- find the process ID of a running program.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>pidof</B>
|
|
|
|
[<B>-s</B>]
|
|
|
|
[<B>-c</B>]
|
|
|
|
[<B>-n</B>]
|
|
|
|
[<B>-x</B>]
|
|
|
|
[<B>-z</B>]
|
|
|
|
[<B>-o</B>
|
|
|
|
<I>omitpid[,omitpid...]</I>]
|
|
|
|
[<B>-o</B>
|
|
|
|
<I>omitpid[,omitpid...]...</I>]
|
|
|
|
[<B>-d</B>
|
|
|
|
<I>sep</I>]
|
|
|
|
<B>program</B>
|
|
|
|
[<B>program...</B>]
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>Pidof</B>
|
|
|
|
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
|
|
<I>System-V</I> like <I>rc</I> 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</B>
|
|
|
|
(8) program that should be used instead.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">-s<DD>
|
|
Single shot - this instructs the program to only return one <I>pid</I>.
|
|
<DT id="2">-c<DD>
|
|
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.
|
|
<DT id="3">-n<DD>
|
|
Avoid
|
|
<B><A HREF="/cgi-bin/man/man2html?2+stat">stat</A></B>(2)
|
|
|
|
system function call on all binaries which are located on network
|
|
based file systems like
|
|
<B>NFS</B>.
|
|
|
|
Instead of using this option the variable
|
|
<B>PIDOF_NETFS</B>
|
|
|
|
may be set and exported.
|
|
<DT id="4">-q<DD>
|
|
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.
|
|
<DT id="5">-x<DD>
|
|
Scripts too - this causes the program to also return process id's of
|
|
shells running the named scripts.
|
|
<DT id="6">-z<DD>
|
|
Try to detect processes which are stuck in uninterruptible (D) or zombie (Z)
|
|
status. Usually these processes are skipped as trying to deal with them can cause
|
|
pidof to hang.
|
|
<DT id="7">-d <I>sep</I><DD>
|
|
Tells <I>pidof</I> to use <I>sep</I> as an output separator if more than one PID
|
|
is shown. The default separator is a space.
|
|
<DT id="8">-o <I>omitpid</I><DD>
|
|
Tells <I>pidof</I> to omit processes with that process id. The special
|
|
pid <B>%PPID</B> can be used to name the parent process of the <I>pidof</I>
|
|
program, in other words the calling shell or shell script.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>EXIT STATUS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="9"><B>0</B>
|
|
|
|
<DD>
|
|
At least one program was found with the requested name.
|
|
<DT id="10"><B>1</B>
|
|
|
|
<DD>
|
|
No program was found with the requested name.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<I>pidof</I> is actually the same program as <I>killall5</I>;
|
|
the program behaves according to the name under which it is called.
|
|
<P>
|
|
|
|
When <I>pidof</I> 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 the executable name of running processes is calculated with
|
|
<B><A HREF="/cgi-bin/man/man2html?2+readlink">readlink</A></B>(2),
|
|
|
|
so symbolic links to executables will also match.
|
|
<P>
|
|
|
|
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.
|
|
The -z flag (see above) tells pidof to try to detect these sleeping and zombie
|
|
processes, at the risk of failing or hanging.
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+shutdown">shutdown</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+init">init</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+halt">halt</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+reboot">reboot</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+killall5">killall5</A></B>(8)
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
Miquel van Smoorenburg, <A HREF="mailto:miquels@cistron.nl">miquels@cistron.nl</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="11"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="12"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="13"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="14"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="15"><A HREF="#lbAF">EXIT STATUS</A><DD>
|
|
<DT id="16"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DT id="17"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
<DT id="18"><A HREF="#lbAI">AUTHOR</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:15 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|