📄 ch38_01.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 38] Starting, Stopping, and Killing Processes</TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:49:27Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="part06.htm"TITLE="VI. Managing Processes "><LINKREL="prev"HREF="part06.htm"TITLE="VI. Managing Processes "><LINKREL="next"HREF="ch38_02.htm"TITLE="38.2 fork and exec "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="PART"HREF="part06.htm"TITLE="VI. Managing Processes "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: VI. Managing Processes "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 38</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch38_02.htm"TITLE="38.2 fork and exec "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 38.2 fork and exec "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="CHAPTER"><H1CLASS="chapter"><ACLASS="title"NAME="UPT-CHP-38">38. Starting, Stopping, and Killing Processes</A></H1><DIVCLASS="htmltoc"><P><B>Contents:</B><BR><ACLASS="sect1"HREF="#UPT-ART-4890"TITLE="38.1 What's in This Chapter ">What's in This Chapter </A><BR><ACLASS="sect1"HREF="ch38_02.htm"TITLE="38.2 fork and exec ">fork and exec </A><BR><ACLASS="sect1"HREF="ch38_03.htm"TITLE="38.3 Managing Processes: Overall Concepts ">Managing Processes: Overall Concepts </A><BR><ACLASS="sect1"HREF="ch38_04.htm"TITLE="38.4 Subshells ">Subshells </A><BR><ACLASS="sect1"HREF="ch38_05.htm"TITLE="38.5 The ps Command ">The ps Command </A><BR><ACLASS="sect1"HREF="ch38_06.htm"TITLE="38.6 The Controlling Terminal ">The Controlling Terminal </A><BR><ACLASS="sect1"HREF="ch38_07.htm"TITLE="38.7 Why ps Prints Some Commands in Parentheses ">Why ps Prints Some Commands in Parentheses </A><BR><ACLASS="sect1"HREF="ch38_08.htm"TITLE="38.8 What Are Signals? ">What Are Signals? </A><BR><ACLASS="sect1"HREF="ch38_09.htm"TITLE="38.9 Killing Foreground Jobs ">Killing Foreground Jobs </A><BR><ACLASS="sect1"HREF="ch38_10.htm"TITLE="38.10 Destroying Processes with kill ">Destroying Processes with kill </A><BR><ACLASS="sect1"HREF="ch38_11.htm"TITLE="38.11 Printer Queue Watcher: A Restartable Daemon Shell Script">Printer Queue Watcher: A Restartable Daemon Shell Script</A><BR><ACLASS="sect1"HREF="ch38_12.htm"TITLE="38.12 Killing All Your Processes ">Killing All Your Processes </A><BR><ACLASS="sect1"HREF="ch38_13.htm"TITLE="38.13 Interactively Kill Processes Matching a Pattern ">Interactively Kill Processes Matching a Pattern </A><BR><ACLASS="sect1"HREF="ch38_14.htm"TITLE="38.14 Processes Out of Control? Just STOP Them ">Processes Out of Control? Just STOP Them </A><BR><ACLASS="sect1"HREF="ch38_15.htm"TITLE="38.15 Cleaning Up an Unkillable Process ">Cleaning Up an Unkillable Process </A><BR><ACLASS="sect1"HREF="ch38_16.htm"TITLE="38.16 Why You Can't Kill a Zombie ">Why You Can't Kill a Zombie </A><BR><ACLASS="sect1"HREF="ch38_17.htm"TITLE="38.17 Automatically Kill Background Processes on Logout in csh">Automatically Kill Background Processes on Logout in csh</A><BR><ACLASS="sect1"HREF="ch38_18.htm"TITLE="38.18 nohup ">nohup </A></P><P></P></DIV><DIVCLASS="sect1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-4890">38.1 What's in This Chapter </A></H2><PCLASS="para">We've already talked about so many of the topics in this chapter,here or there, that it may seem like a real hodgepodge. It's a grab-bag of important things to know about processes - which you can thinkof as programs that are actually running, rather than sitting on thedisk somewhere.</P><PCLASS="para">The chapter starts out with a couple of conceptual articles. Theydefine some important terms that you're likely to encounter inthis chapter.</P><PCLASS="para">Then we talk about the <EMCLASS="emphasis">ps</EM> command, which tells you whatprocesses you have running and just what they are up to (articles<ACLASS="xref"HREF="ch38_05.htm"TITLE="The ps Command ">38.5</A>,<ACLASS="xref"HREF="ch38_06.htm"TITLE="The Controlling Terminal ">38.6</A>,<ACLASS="xref"HREF="ch38_07.htm"TITLE="Why ps Prints Some Commands in Parentheses ">38.7</A>).</P><PCLASS="para">The next few articles cover signals, which are one way processescommunicate with one another. We cover topics like:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">What are signals (article<ACLASS="xref"HREF="ch38_08.htm"TITLE="What Are Signals? ">38.8</A>)?</P></LI><LICLASS="listitem"><PCLASS="para">How to send signals from the keyboard (articles<ACLASS="xref"HREF="ch38_09.htm"TITLE="Killing Foreground Jobs ">38.9</A>and<ACLASS="xref"HREF="ch38_10.htm"TITLE="Destroying Processes with kill ">38.10</A>;also see article<ACLASS="xref"HREF="ch05_09.htm"TITLE="Setting Your Erase, Kill, and Interrupt Characters ">5.9</A>).</P></LI><LICLASS="listitem"><PCLASS="para">How shell programs can "handle" signals (article<ACLASS="xref"HREF="ch38_11.htm"TITLE="Printer Queue Watcher: A Restartable Daemon Shell Script">38.11</A>;also see article<ACLASS="xref"HREF="ch44_12.htm"TITLE="Trapping Exits Caused by Interrupts ">44.12</A>).</P></LI></UL><PCLASS="para">We go from there to a more general discussion of ways to killprocesses:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">How to kill all your processes (article<ACLASS="xref"HREF="ch38_12.htm"TITLE="Killing All Your Processes ">38.12</A>).</P></LI><LICLASS="listitem"><PCLASS="para">How to kill processes by name rather than by process ID (article<ACLASS="xref"HREF="ch38_13.htm"TITLE="Interactively Kill Processes Matching a Pattern ">38.13</A>).</P></LI><LICLASS="listitem"><PCLASS="para">How to stop runaway jobs (article<ACLASS="xref"HREF="ch38_14.htm"TITLE="Processes Out of Control? Just STOP Them ">38.14</A>).</P></LI><LICLASS="listitem"><PCLASS="para">Why some processes don't seem to go away when you kill them (articles<ACLASS="xref"HREF="ch38_15.htm"TITLE="Cleaning Up an Unkillable Process ">38.15</A>,<ACLASS="xref"HREF="ch38_16.htm"TITLE="Why You Can't Kill a Zombie ">38.16</A>).</P></LI><LICLASS="listitem"><PCLASS="para">How to make sure all your processes die when you log out (article<ACLASS="xref"HREF="ch38_17.htm"TITLE="Automatically Kill Background Processes on Logout in csh">38.17</A>).</P></LI><LICLASS="listitem"><PCLASS="para">How to make sure processes <EMCLASS="emphasis">don't</EM> die when you log out (article<ACLASS="xref"HREF="ch38_18.htm"TITLE="nohup ">38.18</A>).</P></LI></UL><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN></P></DIV></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="PART"HREF="part06.htm"TITLE="VI. Managing Processes "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: VI. Managing Processes "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch38_02.htm"TITLE="38.2 fork and exec "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 38.2 fork and exec "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">VI. Managing Processes </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">38.2 fork and exec </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -