Date: Tue, 22 Oct 2013 18:58:13 +0000 (UTC) From: Dru Lavigne <dru@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r43021 - head/en_US.ISO8859-1/books/handbook/basics Message-ID: <201310221858.r9MIwDNd089516@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dru Date: Tue Oct 22 18:58:12 2013 New Revision: 43021 URL: http://svnweb.freebsd.org/changeset/doc/43021 Log: Combine "Processes" and "Daemons, Signals, and Killing Processes" into one section entitled "Processes and Daemons" - introduce daemons and processes in same introductory section - add headings for viewing processes and for killing processes - update listings To be followed by a white space fix. Modified: head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/basics/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Tue Oct 22 10:04:16 2013 (r43020) +++ head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Tue Oct 22 18:58:12 2013 (r43021) @@ -2859,7 +2859,7 @@ root 5211 0.0 0.2 3620 1724 2 </sect1> <sect1 id="basics-processes"> - <title>Processes</title> + <title>Processes and Daemons</title> <para>&os; is a multi-tasking operating system. Each program running at any one time is called a @@ -2877,9 +2877,33 @@ root 5211 0.0 0.2 3620 1724 2 process which has the shell as its parent process. The exception is a special process called &man.init.8; which is always the first process to start at boot time and which always - has a <acronym>PID</acronym> of 1.</para> + has a <acronym>PID</acronym> of <literal>1</literal>.</para> - <para>To see the processes on the system, use &man.ps.1; and + <para>Some programs are not designed + to be run with continuous user input and disconnect from the + terminal at the first opportunity. For example, a web server + responds to web requests, rather than user input. Mail servers + are another example of this type of application. These types of + programs are known as <firstterm>daemons</firstterm>. + The term daemon comes from Greek mythology and represents an + entity that is neither good nor evil, and which invisibly + performs useful tasks. This is why the BSD mascot is the + cheerful-looking daemon with sneakers and a pitchfork.</para> + + <para>There is a convention to name programs that normally run as + daemons with a trailing <quote>d</quote>. For example, + <application>BIND</application> is the Berkeley Internet Name + Domain, but the actual program that executes is <command>named</command>. + The <application>Apache</application> web server program is + <command>httpd</command> and the line printer spooling daemon + is <command>lpd</command>. This is only a naming convention. For example, + the main mail daemon for the <application>Sendmail</application> + application is <command>sendmail</command>, and not + <literal>maild</literal>.</para> + <sect2> + <title>Viewing Processes</title> + + <para>To see the processes running on the system, use &man.ps.1; or &man.top.1;. To display a static list of the currently running processes, their <acronym>PID</acronym>s, how much memory they are using, and the command they were started with, use @@ -2891,21 +2915,9 @@ root 5211 0.0 0.2 3620 1724 2 running and owned by the user. For example:</para> <screen>&prompt.user; <userinput>ps</userinput> - PID TT STAT TIME COMMAND - 298 p0 Ss 0:01.10 tcsh - 7078 p0 S 2:40.88 xemacs mdoc.xsl (xemacs-21.1.14) -37393 p0 I 0:03.11 xemacs freebsd.dsl (xemacs-21.1.14) -72210 p0 R+ 0:00.00 ps - 390 p1 Is 0:01.14 tcsh - 7059 p2 Is+ 1:36.18 /usr/local/bin/mutt -y - 6688 p3 IWs 0:00.00 tcsh -10735 p4 IWs 0:00.00 tcsh -20256 p5 IWs 0:00.00 tcsh - 262 v0 IWs 0:00.00 -tcsh (tcsh) - 270 v0 IW+ 0:00.00 /bin/sh /usr/X11R6/bin/startx -- -bpp 16 - 280 v0 IW+ 0:00.00 xinit /home/nik/.xinitrc -- -bpp 16 - 284 v0 IW 0:00.00 /bin/sh /home/nik/.xinitrc - 285 v0 S 0:38.45 /usr/X11R6/bin/sawfish</screen> + PID TT STAT TIME COMMAND +8203 0 Ss 0:00.59 /bin/csh +8895 0 R+ 0:00.00 ps</screen> <para>The output from &man.ps.1; is organized into a number of columns. The <literal>PID</literal> column displays the process @@ -2922,19 +2934,18 @@ root 5211 0.0 0.2 3620 1724 2 <literal>COMMAND</literal> is the command that was used to start the program.</para> - <para>&man.ps.1; supports a number of different options to change + <para>A number of different options are available to change the information that is displayed. One of the most useful sets - is <literal>auxww</literal>. <option>a</option> displays - information about all the running processes of all users. - <option>u</option> displays the username of the process' owner, - as well as memory usage. <option>x</option> displays + is <literal>auxww</literal>, where <option>a</option> displays + information about all the running processes of all users, + <option>u</option> displays the username and memory usage of the process' owner, + <option>x</option> displays information about daemon processes, and <option>ww</option> causes &man.ps.1; to display the full command line for each process, rather than truncating it once it gets too long to fit on the screen.</para> - <para>The output from &man.top.1; is similar. A sample session - looks like this:</para> + <para>The output from &man.top.1; is similar:</para> <screen>&prompt.user; <userinput>top</userinput> last pid: 72257; load averages: 0.13, 0.09, 0.03 up 0+13:38:33 22:39:10 @@ -2943,23 +2954,38 @@ CPU states: 12.6% user, 0.0% nice, 7.8 Mem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K Free Swap: 256M Total, 38M Used, 217M Free, 15% Inuse - PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND -72257 nik 28 0 1960K 1044K RUN 0:00 14.86% 1.42% top - 7078 nik 2 0 15280K 10960K select 2:54 0.88% 0.88% xemacs-21.1.14 - 281 nik 2 0 18636K 7112K select 5:36 0.73% 0.73% XF86_SVGA - 296 nik 2 0 3240K 1644K select 0:12 0.05% 0.05% xterm - 175 root 2 0 924K 252K select 1:41 0.00% 0.00% syslogd - 7059 nik 2 0 7260K 4644K poll 1:38 0.00% 0.00% mutt -...</screen> +last pid: 9609; load averages: 0.56, 0.45, 0.36 up 0+00:20:03 10:21:46 +107 processes: 2 running, 104 sleeping, 1 zombie +CPU: 6.2% user, 0.1% nice, 8.2% system, 0.4% interrupt, 85.1% idle +Mem: 541M Active, 450M Inact, 1333M Wired, 4064K Cache, 1498M Free +ARC: 992M Total, 377M MFU, 589M MRU, 250K Anon, 5280K Header, 21M Other +Swap: 2048M Total, 2048M Free + + PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND + 557 root 1 -21 r31 136M 42296K select 0 2:20 9.96% Xorg + 8198 dru 2 52 0 449M 82736K select 3 0:08 5.96% kdeinit4 + 8311 dru 27 30 0 1150M 187M uwait 1 1:37 0.98% firefox + 431 root 1 20 0 14268K 1728K select 0 0:06 0.98% moused + 9551 dru 1 21 0 16600K 2660K CPU3 3 0:01 0.98% top + 2357 dru 4 37 0 718M 141M select 0 0:21 0.00% kdeinit4 + 8705 dru 4 35 0 480M 98M select 2 0:20 0.00% kdeinit4 + 8076 dru 6 20 0 552M 113M uwait 0 0:12 0.00% soffice.bin + 2623 root 1 30 10 12088K 1636K select 3 0:09 0.00% powerd + 2338 dru 1 20 0 440M 84532K select 1 0:06 0.00% kwin + 1427 dru 5 22 0 605M 86412K select 1 0:05 0.00% kdeinit4</screen> <para>The output is split into two sections. The header (the - first five lines) shows the <acronym>PID</acronym> of the last + first five or six lines) shows the <acronym>PID</acronym> of the last process to run, the system load averages (which are a measure of how busy the system is), the system uptime (time since the last reboot) and the current time. The other figures in the - header relate to how many processes are running (47 in this - case), how much memory and swap space has been used, and how - much time the system is spending in different CPU states.</para> + header relate to how many processes are running, + how much memory and swap space has been used, and how + much time the system is spending in different CPU states. If + the system has been formatted with the <acronym>ZFS</acronym> + file system, the <literal>ARC</literal> line provides an + indication of how much data was read from the memory cache + instead of from disk.</para> <para>Below the header is a series of columns containing similar information to the output from &man.ps.1;, such as the @@ -2969,46 +2995,18 @@ Swap: 256M Total, 38M Used, 217M Free, 1 This is split into two columns: one for total size and one for resident size. Total size is how much memory the application has needed and the resident size is how much it is actually - using at the moment. In this example, - <application>mutt</application> has required almost 8 MB - of RAM, but is currently only using 5 MB.</para> + using now.</para> <para>&man.top.1; automatically updates the display every two seconds. A different interval can be specified with <option>-s</option>.</para> - </sect1> + </sect2> - <sect1 id="basics-daemons"> - <title>Daemons, Signals, and Killing Processes</title> - - <para>When using an editor, it is easy to control the editor and - load files because the editor provides facilities to do so, and - because the editor is attached to a - <firstterm>terminal</firstterm>. Some programs are not designed - to be run with continuous user input and disconnect from the - terminal at the first opportunity. For example, a web server - responds to web requests, rather than user input. Mail servers - are another example of this type of application.</para> - - <para>These programs are known as <firstterm>daemons</firstterm>. - The term daemon comes from Greek mythology and represents an - entity that is neither good or evil, and which invisibly - performs useful tasks. This is why the BSD mascot is the - cheerful-looking daemon with sneakers and a pitchfork.</para> - - <para>There is a convention to name programs that normally run as - daemons with a trailing <quote>d</quote>. - <application>BIND</application> is the Berkeley Internet Name - Domain, but the actual program that executes is &man.named.8;. - The <application>Apache</application> web server program is - <command>httpd</command> and the line printer spooling daemon - is &man.lpd.8;. This is only a naming convention. For example, - the main mail daemon for the <application>Sendmail</application> - application is &man.sendmail.8;, and not - <literal>maild</literal>.</para> + <sect2 id="basics-daemons"> + <title>Killing Processes</title> - <para>One way to communicate with a daemon, or any running - process, is to send a <firstterm>signal</firstterm> using + <para>One way to communicate with any running + process or daemon is to send a <firstterm>signal</firstterm> using &man.kill.1;. There are a number of different signals; some have a specific meaning while others are described in the application's documentation. A user can only send a signal to a @@ -3017,13 +3015,13 @@ Swap: 256M Total, 38M Used, 217M Free, 1 <username>root</username> user, who can send signals to anyone's processes.</para> - <para>&os; can also send a signal to a process. If an application + <para>The operating system can also send a signal to a process. If an application is badly written and tries to access memory that it is not supposed to, &os; will send the process the - <firstterm>Segmentation Violation</firstterm> signal - (<literal>SIGSEGV</literal>). If an application has used the + <quote>Segmentation Violation</quote> signal + (<literal>SIGSEGV</literal>). If an application has been written to use the &man.alarm.3; system call to be alerted after a period of time - has elapsed, it will be sent the Alarm signal + has elapsed, it will be sent the <quote>Alarm</quote> signal (<literal>SIGALRM</literal>).</para> <para>Two signals can be used to stop a process: @@ -3036,8 +3034,7 @@ Swap: 256M Total, 38M Used, 217M Free, 1 that can not be interrupted.</para> <para><literal>SIGKILL</literal> can not be ignored by a process. - This is the <quote>I do not care what you are doing, stop right - now</quote> signal. Sending a <literal>SIGKILL</literal> to a + Sending a <literal>SIGKILL</literal> to a process will usually stop that process there and then.<footnote> <para>There are a few tasks that can not be interrupted. For example, if the process is trying to read from a file that @@ -3050,7 +3047,7 @@ Swap: 256M Total, 38M Used, 217M Free, 1 <para>Other commonly used signals are <literal>SIGHUP</literal>, <literal>SIGUSR1</literal>, and <literal>SIGUSR2</literal>. - These are general purpose signals and different applications + Since these are general purpose signals, different applications will respond differently.</para> <para>For example, after changing a web server's configuration @@ -3112,19 +3109,17 @@ Swap: 256M Total, 38M Used, 217M Free, 1 <filename>/bin/kill</filename>. Be aware that different shells have a different syntax for specifying the name of the signal to send. Rather than try to learn all of them, - it can be simpler to use <command>/bin/kill - <replaceable>...</replaceable></command> - directly.</para> + it can be simpler to specify <command>/bin/kill</command>.</para> </note> </step> </procedure> <para>When sending other signals, substitute - <literal>TERM</literal> or <literal>KILL</literal> in the - command line as necessary.</para> + <literal>TERM</literal> or <literal>KILL</literal> with the name + of the signal.</para> <important> - <para>Killing a random process on the system can be a bad idea. + <para>Killing a random process on the system is a bad idea. In particular, &man.init.8;, <acronym>PID</acronym> 1, is special. Running <command>/bin/kill -s KILL 1</command> is a quick, and unrecommended, way to shutdown the system. @@ -3132,6 +3127,7 @@ Swap: 256M Total, 38M Used, 217M Free, 1 &man.kill.1; <emphasis>before</emphasis> pressing <keycap>Return</keycap>.</para> </important> + </sect2> </sect1> <sect1 id="shells">
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310221858.r9MIwDNd089516>