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

📄 ch12_07.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 12] 12.7 Stop Background Output with stty tostop </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:36:31Z"><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="ch12_01.htm"TITLE="12. Job Control"><LINKREL="prev"HREF="ch12_06.htm"TITLE="12.6 Notification When Jobs Change State "><LINKREL="next"HREF="ch12_08.htm"TITLE="12.8 Job Control in a Nutshell "></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="ch12_06.htm"TITLE="12.6 Notification When Jobs Change State "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 12.6 Notification When Jobs Change State "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 12<BR>Job Control</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch12_08.htm"TITLE="12.8 Job Control in a Nutshell "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 12.8 Job Control in a Nutshell "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-6590">12.7 Stop Background Output with stty tostop </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-13748"></A><ACLASS="indexterm"NAME="AUTOID-13751"></A><ACLASS="indexterm"NAME="AUTOID-13754"></A><ACLASS="indexterm"NAME="AUTOID-13757"></A><ACLASS="indexterm"NAME="AUTOID-13760"></A>If you put a job in the<SPANCLASS="link">background (<ACLASS="linkend"HREF="ch01_26.htm"TITLE="What a Multiuser System Can Do for You ">1.26</A>)</SPAN>and don't<SPANCLASS="link">redirect (<ACLASS="linkend"HREF="ch13_01.htm#UPT-ART-1023"TITLE="Using Standard Input and Output">13.1</A>)</SPAN>its output,text that the job writes to its standard output and standard error willcome to your screen.Those messages can mess up the screen while you're using another program.You could lose the (maybe important) messages, too&nbsp;- they might scroll offyour screen and be lost, or your foreground program may clear the screenand erase them.</P><PCLASS="para">Most BSD UNIX systems, and a lot of newer UNIXes withjob control,have the command <EMCLASS="emphasis">stty tostop</EM>.Type that command at a prompt, or put it in your<SPANCLASS="link"><EMCLASS="emphasis">.login</EM> or <EMCLASS="emphasis">.profile</EM> file (<ACLASS="linkend"HREF="ch02_01.htm#UPT-ART-4790"TITLE="Customizing the Shell ">2.1</A>)</SPAN>.*[2]After that, your shell'sbackground jobs that try to write to your terminal will be stopped.When you want to see the background job's output, bring it into theforeground (with <EMCLASS="emphasis">fg</EM>).</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[2] *This command sets the UNIX terminal<SPANCLASS="link">device driver (<ACLASS="linkend"HREF="ch42_01.htm#UPT-ART-1142"TITLE="Making Sense Out of the Terminal Mess ">42.1</A>)</SPAN>for all processes startedon it.<SPANCLASS="link">You don't need to set this for subshells (<ACLASS="linkend"HREF="ch02_02.htm"TITLE="Shell Setup Files-Which, Where, and Why ">2.2</A>)</SPAN>.</P></BLOCKQUOTE><PCLASS="para">How will you know that the background job has been stopped?The shell will print a message like this just before it prints a prompt:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">[1] + Stopped (tty output)    <CODECLASS="replaceable"><I>somejob</I></CODE>%</PRE></BLOCKQUOTE></P><PCLASS="para">The shell can also interrupt your foreground job with that message as soon asthe background job is stopped.To make it do that, set<SPANCLASS="link"><EMCLASS="emphasis">notify</EM> (<ACLASS="linkend"HREF="ch12_06.htm"TITLE="Notification When Jobs Change State ">12.6</A>)</SPAN>.</P><PCLASS="para">You can turn off this feature and let background jobs write to your terminalany time with the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>stty -tostop</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Article<ACLASS="xref"HREF="ch41_02.htm"TITLE="stty and All That Stuff ">41.2</A>has more about <EMCLASS="emphasis">stty</EM>.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</SPAN></P></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="SECT1"HREF="ch12_06.htm"TITLE="12.6 Notification When Jobs Change State "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 12.6 Notification When Jobs Change State "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="ch12_08.htm"TITLE="12.8 Job Control in a Nutshell "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 12.8 Job Control in a Nutshell "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">12.6 Notification When Jobs Change State </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">12.8 Job Control in a Nutshell </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 &amp; 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 + -