⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch38_03.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 38] 38.3 Managing Processes: Overall Concepts </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:49:30Z"><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="ch38_01.htm"TITLE="38. Starting, Stopping, and Killing Processes"><LINKREL="prev"HREF="ch38_02.htm"TITLE="38.2 fork and exec "><LINKREL="next"HREF="ch38_04.htm"TITLE="38.4 Subshells "></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="SECT1"HREF="ch38_02.htm"TITLE="38.2 fork and exec "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 38.2 fork and exec "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 38<BR>Starting, Stopping, and Killing Processes</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch38_04.htm"TITLE="38.4 Subshells "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 38.4 Subshells "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-1870">38.3 Managing Processes: Overall Concepts </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-1870-IX-PROCESSES-MANAGING"></A><ACLASS="indexterm"NAME="AUTOID-42234"></A><ACLASS="indexterm"NAME="AUTOID-42237"></A><ACLASS="indexterm"NAME="AUTOID-42239"></A>As you know, when you log into your UNIX account andstart typing, you're talking to the<SPANCLASS="link"><BCLASS="emphasis.bold">shell</B> (<ACLASS="linkend"HREF="ch08_01.htm#UPT-ART-1810"TITLE="What the Shell Does ">8.1</A>)</SPAN>.The shell you use may be a variant of theBourne shell (such as a standard <EMCLASS="emphasis">sh</EM>, or <EMCLASS="emphasis">ksh</EM> or the GNUshell <EMCLASS="emphasis">bash</EM>), or perhaps it is a variant of the C shell,<EMCLASS="emphasis">csh</EM> (such as, perhaps, the <EMCLASS="emphasis">tcsh</EM> shell that includesline- and history-editing features). Alternatively, you may be usinga somewhat less common shell such as <EMCLASS="emphasis">rc</EM>.</P><PCLASS="para">Your shell is a <BCLASS="emphasis.bold">process</B>, one of many individual programs runningat the same time on the machine. Every process has certain pieces ofinformation associated with it, including:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42254"></A>The <BCLASS="emphasis.bold">process ID</B> (PID) is a number assigned to the process when it isstarted up. Process IDs are unique (that is, they cycle and areeventually re-used, but no two processes have the same process ID atthe same time).</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42259"></A><ACLASS="indexterm"NAME="AUTOID-42261"></A><ACLASS="indexterm"NAME="AUTOID-42264"></A>The <BCLASS="emphasis.bold">user ID</B> (UID) tells who the process belongs to. This determines<SPANCLASS="link"> what files and directories the process is allowed to read from or write to, (<ACLASS="linkend"HREF="ch22_01.htm#UPT-ART-5010"TITLE="Introduction to File Ownership and Security ">22.1</A>)</SPAN>as well as who is allowed to<SPANCLASS="link"><EMCLASS="emphasis">kill</EM> the process (<ACLASS="linkend"HREF="ch38_10.htm"TITLE="Destroying Processes with kill ">38.10</A>)</SPAN>(tell it to stop running).</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42273"></A>The <BCLASS="emphasis.bold">group ID</B> (GID) is similar to the user ID, but tells whichgroup the process belongs to.On some systems, this controls the groupassigned to files created by the process.See articles<ACLASS="xref"HREF="ch22_05.htm"TITLE="Group Permissions in a Directory with the setgid Bit ">22.5</A>,<ACLASS="xref"HREF="ch22_13.htm"TITLE="Groups and Group Ownership ">22.13</A>,and<ACLASS="xref"HREF="ch22_02.htm"TITLE="Tutorial on File and Directory Permissions ">22.2</A>.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42281"></A>The <BCLASS="emphasis.bold">environment</B> contains a list of variables and associatedvalues. For example, when you type <CODECLASS="literal">echo</CODE> <CODECLASS="literal">$HOME</CODE>at the shell and it prints out the name of your<SPANCLASS="link">home directory (<ACLASS="linkend"HREF="ch01_20.htm"TITLE="Your Home Directory ">1.20</A>)</SPAN>,it hastold you the contents of the<SPANCLASS="link"><BCLASS="emphasis.bold">environment variable</B> (<ACLASS="linkend"HREF="ch06_01.htm#UPT-ART-1170"TITLE="What Environment Variables Are Good For ">6.1</A>)</SPAN>called <EMCLASS="emphasis">HOME</EM>.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42292"></A><ACLASS="indexterm"NAME="AUTOID-42294"></A>The<SPANCLASS="link"><BCLASS="emphasis.bold">current working directory</B> (<ACLASS="linkend"HREF="ch14_03.htm"TITLE="What Good Is a Current Directory? ">14.3</A>)</SPAN>is the directorythat is currently the default. When you specify afilename to a program but do not say explicitly where to look forit [with a<SPANCLASS="link">pathname (<ACLASS="linkend"HREF="ch14_02.htm"TITLE="Using Relative and Absolute Pathnames ">14.2</A>)</SPAN><EMCLASS="emphasis">-JP</EM> ], the program will look in the current workingdirectory-if the <EMCLASS="emphasis">PATH</EM> variable contains the current directory(article<ACLASS="xref"HREF="ch06_04.htm"TITLE="The PATH Environment Variable ">6.4</A>explains).</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">File descriptors</B> are a record of which files a process hasopened for reading or writing, as well as the current position ineach file.<ACLASS="indexterm"NAME="AUTOID-42306"></A>Articles<ACLASS="xref"HREF="ch45_20.htm"TITLE="Overview: Open Files and File Descriptors ">45.20</A>through<ACLASS="xref"HREF="ch45_23.htm"TITLE="The Ins and Outs of Redirected I/O Loops ">45.23</A>explain file descriptor use in the Bourne shell.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42312"></A><ACLASS="indexterm"NAME="AUTOID-42314"></A>Versions of UNIX with<SPANCLASS="link">job control (<ACLASS="linkend"HREF="ch12_08.htm"TITLE="Job Control in a Nutshell ">12.8</A>)</SPAN>have <BCLASS="emphasis.bold">process groups</B>.A process group is used for<SPANCLASS="link">distribution of signals (<ACLASS="linkend"HREF="ch38_08.htm"TITLE="What Are Signals? ">38.8</A>, <ACLASS="linkend"HREF="ch38_09.htm"TITLE="Killing Foreground Jobs ">38.9</A>, <ACLASS="linkend"HREF="ch38_12.htm"TITLE="Killing All Your Processes ">38.12</A>)</SPAN>.It's also used to control which process can read from a terminal.A process that has the same process group as the terminal is&quot;in the foreground&quot; and can read from the terminal.Other processes are stopped when they try to read from the terminal.</P></LI></UL><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-42321"></A><ACLASS="indexterm"NAME="AUTOID-42323"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -