亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? library_22.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Process Startup and Termination</TITLE>
<P>Go to the <A HREF="library_21.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html">previous</A>, <A HREF="library_23.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html">next</A> section.<P>
<H1><A NAME="SEC385" HREF="library_toc.html#SEC385" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC385">Process Startup and Termination</A></H1>
<A NAME="IDX1622"></A>
<P>
<DFN>Processes</DFN> are the primitive units for allocation of system
resources.  Each process has its own address space and (usually) one
thread of control.  A process executes a program; you can have multiple
processes executing the same program, but each process has its own copy
of the program within its own address space and executes it
independently of the other copies.
<P>
This chapter explains what your program should do to handle the startup
of a process, to terminate its process, and to receive information
(arguments and the environment) from the parent process.
<P>
<A NAME="IDX1623"></A>
<A NAME="IDX1624"></A>
<H2><A NAME="SEC386" HREF="library_toc.html#SEC386" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC386">Program Arguments</A></H2>
<A NAME="IDX1625"></A>
<P>
The system starts a C program by calling the function <CODE>main</CODE>.  It
is up to you to write a function named <CODE>main</CODE>---otherwise, you
won't even be able to link your program without errors.
<P>
You can define <CODE>main</CODE> either to take no arguments, or to take two
arguments that represent the command line arguments to the program, like
this:
<P>
<PRE>
int main (int <VAR>argc</VAR>, char *<VAR>argv</VAR>[])
</PRE>
<A NAME="IDX1626"></A>
<A NAME="IDX1627"></A>
<P>
The command line arguments are the whitespace-separated tokens given in
the shell command used to invoke the program; thus, in <SAMP>`cat foo
bar'</SAMP>, the arguments are <SAMP>`foo'</SAMP> and <SAMP>`bar'</SAMP>.  The only way a
program can look at its command line arguments is via the arguments of
<CODE>main</CODE>.  If <CODE>main</CODE> doesn't take arguments, then you cannot get
at the command line.
<P>
The value of the <VAR>argc</VAR> argument is the number of command line
arguments.  The <VAR>argv</VAR> argument is a vector of C strings; its
elements are the individual command line argument strings.  The file
name of the program being run is also included in the vector as the
first element; the value of <VAR>argc</VAR> counts this element.  A null
pointer always follows the last element: <CODE><VAR>argv</VAR>[<VAR>argc</VAR>]</CODE>
is this null pointer.
<P>
For the command <SAMP>`cat foo bar'</SAMP>, <VAR>argc</VAR> is 3 and <VAR>argv</VAR> has
three elements, <CODE>"cat"</CODE>, <CODE>"foo"</CODE> and <CODE>"bar"</CODE>.
<P>
If the syntax for the command line arguments to your program is simple
enough, you can simply pick the arguments off from <VAR>argv</VAR> by hand.
But unless your program takes a fixed number of arguments, or all of the
arguments are interpreted in the same way (as file names, for example),
you are usually better off using <CODE>getopt</CODE> to do the parsing.
<P>
<A NAME="IDX1628"></A>
<A NAME="IDX1629"></A>
<A NAME="IDX1630"></A>
<H3><A NAME="SEC387" HREF="library_toc.html#SEC387" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC387">Program Argument Syntax Conventions</A></H3>
<P>
POSIX recommends these conventions for command line arguments.
<CODE>getopt</CODE> (see section <A HREF="library_22.html#SEC388" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC388">Parsing Program Options</A>) makes it easy to implement them.
<P>
<UL>
<LI>
Arguments are options if they begin with a hyphen delimiter (<SAMP>`-'</SAMP>).
<P>
<LI>
Multiple options may follow a hyphen delimiter in a single token if
the options do not take arguments.  Thus, <SAMP>`-abc'</SAMP> is equivalent to
<SAMP>`-a -b -c'</SAMP>.
<P>
<LI>
Option names are single alphanumeric characters (as for <CODE>isalnum</CODE>;
see section <A HREF="library_4.html#SEC55" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_4.html#SEC55">Classification of Characters</A>).
<P>
<LI>
Certain options require an argument.  For example, the <SAMP>`-o'</SAMP> command
of the <CODE>ld</CODE> command requires an argument--an output file name.
<P>
<LI>
An option and its argument may or may not appear as separate tokens.  (In
other words, the whitespace separating them is optional.)  Thus,
<SAMP>`-o foo'</SAMP> and <SAMP>`-ofoo'</SAMP> are equivalent.
<P>
<LI>
Options typically precede other non-option arguments.
<P>
The implementation of <CODE>getopt</CODE> in the GNU C library normally makes
it appear as if all the option arguments were specified before all the
non-option arguments for the purposes of parsing, even if the user of
your program intermixed option and non-option arguments.  It does this
by reordering the elements of the <VAR>argv</VAR> array.  This behavior is
nonstandard; if you want to suppress it, define the
<CODE>_POSIX_OPTION_ORDER</CODE> environment variable.  See section <A HREF="library_22.html#SEC394" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC394">Standard Environment Variables</A>.
<P>
<LI>
The argument <SAMP>`--'</SAMP> terminates all options; any following arguments
are treated as non-option arguments, even if they begin with a hyphen.
<P>
<LI>
A token consisting of a single hyphen character is interpreted as an
ordinary non-option argument.  By convention, it is used to specify
input from or output to the standard input and output streams.
<P>
<LI>
Options may be supplied in any order, or appear multiple times.  The
interpretation is left up to the particular application program.
</UL>
<A NAME="IDX1631"></A>
<P>
GNU adds <DFN>long options</DFN> to these conventions.  Long options consist
of <SAMP>`--'</SAMP> followed by a name made of alphanumeric characters and
dashes.  Option names are typically one to three words long, with
hyphens to separate words.  Users can abbreviate the option names as
long as the abbreviations are unique.
<P>
To specify an argument for a long option, write
<SAMP>`--<VAR>name</VAR>=<VAR>value</VAR>'</SAMP>.  This syntax enables a long option to
accept an argument that is itself optional.
<P>
Eventually, the GNU system will provide completion for long option names
in the shell.
<P>
<A NAME="IDX1632"></A>
<A NAME="IDX1633"></A>
<A NAME="IDX1634"></A>
<H3><A NAME="SEC388" HREF="library_toc.html#SEC388" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC388">Parsing Program Options</A></H3>
<P>
Here are the details about how to call the <CODE>getopt</CODE> function.  To
use this facility, your program must include the header file
<TT>`unistd.h'</TT>.
<A NAME="IDX1635"></A>
<P>
<A NAME="IDX1636"></A>
<U>Variable:</U> int <B>opterr</B><P>
If the value of this variable is nonzero, then <CODE>getopt</CODE> prints an
error message to the standard error stream if it encounters an unknown
option character or an option with a missing required argument.  This is
the default behavior.  If you set this variable to zero, <CODE>getopt</CODE>
does not print any messages, but it still returns the character <CODE>?</CODE>
to indicate an error.
<P>
<A NAME="IDX1637"></A>
<U>Variable:</U> int <B>optopt</B><P>
When <CODE>getopt</CODE> encounters an unknown option character or an option
with a missing required argument, it stores that option character in
this variable.  You can use this for providing your own diagnostic
messages.
<P>
<A NAME="IDX1638"></A>
<U>Variable:</U> int <B>optind</B><P>
This variable is set by <CODE>getopt</CODE> to the index of the next element
of the <VAR>argv</VAR> array to be processed.  Once <CODE>getopt</CODE> has found
all of the option arguments, you can use this variable to determine
where the remaining non-option arguments begin.  The initial value of
this variable is <CODE>1</CODE>.
<P>
<A NAME="IDX1639"></A>
<U>Variable:</U> char * <B>optarg</B><P>
This variable is set by <CODE>getopt</CODE> to point at the value of the
option argument, for those options that accept arguments.
<P>
<A NAME="IDX1640"></A>
<U>Function:</U> int <B>getopt</B> <I>(int <VAR>argc</VAR>, char **<VAR>argv</VAR>, const char *<VAR>options</VAR>)</I><P>
The <CODE>getopt</CODE> function gets the next option argument from the
argument list specified by the <VAR>argv</VAR> and <VAR>argc</VAR> arguments.
Normally these values come directly from the arguments received by
<CODE>main</CODE>.
<P>
The <VAR>options</VAR> argument is a string that specifies the option
characters that are valid for this program.  An option character in this
string can be followed by a colon (<SAMP>`:'</SAMP>) to indicate that it takes a
required argument.
<P>
If the <VAR>options</VAR> argument string begins with a hyphen (<SAMP>`-'</SAMP>), this
is treated specially.  It permits arguments that are not options to be
returned as if they were associated with option character <SAMP>`\0'</SAMP>.
<P>
The <CODE>getopt</CODE> function returns the option character for the next
command line option.  When no more option arguments are available, it
returns <CODE>-1</CODE>.  There may still be more non-option arguments; you
must compare the external variable <CODE>optind</CODE> against the <VAR>argc</VAR>
parameter to check this.
<P>
If the option has an argument, <CODE>getopt</CODE> returns the argument by
storing it in the varables <VAR>optarg</VAR>.  You don't ordinarily need to
copy the <CODE>optarg</CODE> string, since it is a pointer into the original
<VAR>argv</VAR> array, not into a static area that might be overwritten.
<P>
If <CODE>getopt</CODE> finds an option character in <VAR>argv</VAR> that was not
included in <VAR>options</VAR>, or a missing option argument, it returns
<SAMP>`?'</SAMP> and sets the external variable <CODE>optopt</CODE> to the actual
option character.  If the first character of <VAR>options</VAR> is a colon
(<SAMP>`:'</SAMP>), then <CODE>getopt</CODE> returns <SAMP>`:'</SAMP> instead of <SAMP>`?'</SAMP> to
indicate a missing option argument.  In addition, if the external
variable <CODE>opterr</CODE> is nonzero (which is the default), <CODE>getopt</CODE>
prints an error message.
<P>
<H3><A NAME="SEC389" HREF="library_toc.html#SEC389" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC389">Example of Parsing Arguments with <CODE>getopt</CODE></A></H3>
<P>
Here is an example showing how <CODE>getopt</CODE> is typically used.  The
key points to notice are:
<P>
<UL>
<LI>
Normally, <CODE>getopt</CODE> is called in a loop.  When <CODE>getopt</CODE> returns
<CODE>-1</CODE>, indicating no more options are present, the loop terminates.
<P>
<LI>
A <CODE>switch</CODE> statement is used to dispatch on the return value from
<CODE>getopt</CODE>.  In typical use, each case just sets a variable that
is used later in the program.
<P>
<LI>
A second loop is used to process the remaining non-option arguments.
</UL>
<P>
<PRE>
#include &#60;unistd.h&#62;
#include &#60;stdio.h&#62;

int 
main (int argc, char **argv)
{
  int aflag = 0;
  int bflag = 0;
  char *cvalue = NULL;
  int index;
  int c;

  opterr = 0;

  while ((c = getopt (argc, argv, "abc:")) != -1)
    switch (c)
      {
      case 'a':
        aflag = 1;
        break;
      case 'b':
        bflag = 1;
        break;
      case 'c':
        cvalue = optarg;
        break;
      case '?':
        if (isprint (optopt))
          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
        else
          fprintf (stderr,
                   "Unknown option character `\\x%x'.\n",
                   optopt);
        return 1;
      default:
        abort ();
      }

  printf ("aflag = %d, bflag = %d, cvalue = %s\n", aflag, bflag, cvalue);

  for (index = optind; index &#60; argc; index++)
    printf ("Non-option argument %s\n", argv[index]);
  return 0;
}
</PRE>
<P>
Here are some examples showing what this program prints with different
combinations of arguments:
<P>
<PRE>
% testopt
aflag = 0, bflag = 0, cvalue = (null)

% testopt -a -b
aflag = 1, bflag = 1, cvalue = (null)

% testopt -ab
aflag = 1, bflag = 1, cvalue = (null)

% testopt -c foo
aflag = 0, bflag = 0, cvalue = foo

% testopt -cfoo
aflag = 0, bflag = 0, cvalue = foo

% testopt arg1
aflag = 0, bflag = 0, cvalue = (null)
Non-option argument arg1

% testopt -a arg1
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument arg1

% testopt -c foo arg1
aflag = 0, bflag = 0, cvalue = foo
Non-option argument arg1

% testopt -a -- -b
aflag = 1, bflag = 0, cvalue = (null)
Non-option argument -b

% testopt -a -
aflag = 1, bflag = 0, cvalue = (null)

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合给合久久狠狠狠97色69| av在线综合网| 欧美一级欧美三级在线观看 | 91免费小视频| 国产精品理伦片| 日本道精品一区二区三区| 一区二区三区**美女毛片| 欧美三级中文字幕| 老司机精品视频线观看86| 久久久久久电影| 91丨九色丨国产丨porny| 亚洲在线成人精品| 日韩视频123| 国产精品主播直播| 日韩理论电影院| 欧美人xxxx| 狠狠色2019综合网| 国产精品久久久久久久蜜臀| 欧美三片在线视频观看| 久久国产欧美日韩精品| 国产精品乱人伦中文| 欧美伊人精品成人久久综合97| 丝袜国产日韩另类美女| 久久久99免费| 99麻豆久久久国产精品免费 | 国产精品久久久久久久久图文区| 91日韩精品一区| 日本伊人午夜精品| 欧美国产97人人爽人人喊| 色一情一伦一子一伦一区| 日本不卡在线视频| 日韩一区中文字幕| 日韩一区二区三| caoporn国产精品| 免费成人结看片| 最近日韩中文字幕| 精品美女在线播放| 在线观看三级视频欧美| 国产一区二区三区免费在线观看| 亚洲欧美日韩中文字幕一区二区三区| 欧美一区二区精美| 92精品国产成人观看免费| 美女视频黄频大全不卡视频在线播放| 中文字幕在线播放不卡一区| 日韩一区二区精品| 欧美在线一区二区| www.亚洲人| 韩国视频一区二区| 亚洲成人动漫一区| 亚洲色图另类专区| 国产三级精品在线| 日韩精品中文字幕一区| 欧美综合一区二区| av中文字幕亚洲| 国产福利精品导航| 久久99精品国产91久久来源| 亚洲国产精品天堂| 一区二区在线观看免费| 国产精品丝袜黑色高跟| 日韩精品一区二区三区蜜臀| 欧美日韩一区二区三区不卡| 一本久久综合亚洲鲁鲁五月天| 国产一区二区在线观看视频| 日韩成人精品在线观看| 亚洲国产视频网站| 亚洲品质自拍视频| 国产精品高潮久久久久无| 久久久亚洲高清| 26uuu亚洲| 26uuu国产在线精品一区二区| 4438成人网| 日韩一区二区精品| 日韩欧美色综合网站| 911精品国产一区二区在线| 欧美日韩一级大片网址| 欧美日韩另类一区| 欧美视频在线一区| 欧美精品乱码久久久久久| 欧美亚洲自拍偷拍| 欧美性一区二区| 欧美最猛性xxxxx直播| 欧美亚洲综合色| 欧美日韩国产免费一区二区| 欧美无乱码久久久免费午夜一区| 色网站国产精品| 在线免费精品视频| 欧美人成免费网站| 日韩亚洲欧美一区二区三区| 久久综合久久鬼色中文字| 久久综合久久鬼色| 国产精品天干天干在线综合| 国产精品第四页| 亚洲精品国产成人久久av盗摄| 亚洲国产一区二区三区青草影视| 欧美日高清视频| 在线观看一区二区视频| 欧美三级视频在线观看| 欧美精品日韩一区| 日韩欧美激情一区| 久久视频一区二区| 国产精品无人区| 亚洲精品伦理在线| 日韩av电影免费观看高清完整版 | 懂色中文一区二区在线播放| 国产福利91精品一区二区三区| 成a人片国产精品| 色综合久久久久网| 欧美日韩视频在线第一区| 在线播放国产精品二区一二区四区 | 日韩伦理电影网| 天天操天天综合网| 国产一区二区三区av电影| 成人丝袜视频网| 欧美性极品少妇| 久久久欧美精品sm网站| 亚洲美女免费视频| 麻豆91在线播放| av一本久道久久综合久久鬼色| 欧美三区在线观看| 久久精品亚洲一区二区三区浴池| 亚洲欧美在线视频观看| 日本亚洲天堂网| thepron国产精品| 欧美一区二区三区色| 中文幕一区二区三区久久蜜桃| 一二三区精品福利视频| 久久99精品国产.久久久久| 色香蕉久久蜜桃| 久久精品一区二区三区四区| 亚洲精品综合在线| 国产主播一区二区| 欧美女孩性生活视频| 国产精品美日韩| 久久精品久久久精品美女| 99精品在线免费| 久久丝袜美腿综合| 日韩av午夜在线观看| 91在线免费看| 国产亚洲精品精华液| 日本不卡视频一二三区| 日本道色综合久久| 国产精品毛片大码女人| 精品在线免费观看| 欧美人与禽zozo性伦| 成人免费在线播放视频| 国产尤物一区二区| 日韩欧美第一区| 亚洲一级在线观看| 97久久精品人人爽人人爽蜜臀 | 4438亚洲最大| 亚洲制服丝袜av| 99v久久综合狠狠综合久久| 久久亚洲春色中文字幕久久久| 日韩中文字幕亚洲一区二区va在线 | **网站欧美大片在线观看| 九一九一国产精品| 欧美一区二区黄| 同产精品九九九| 欧美日韩一区久久| 亚洲韩国一区二区三区| 色狠狠桃花综合| 一区二区三区日韩| 一本色道亚洲精品aⅴ| ㊣最新国产の精品bt伙计久久| 国产91在线观看| 久久精品欧美日韩精品| 国产精品亚洲视频| 国产女人18水真多18精品一级做| 国产一区二区电影| 国产亚洲欧美在线| 国产剧情一区在线| 国产精品午夜在线观看| 懂色av一区二区在线播放| 国产欧美精品一区二区三区四区| 国产高清亚洲一区| 国产精品色呦呦| 91亚洲永久精品| 亚洲精品国产成人久久av盗摄| 在线免费观看视频一区| 亚洲国产人成综合网站| 9191国产精品| 国产在线精品一区二区不卡了| 久久综合资源网| 成人h动漫精品| 亚洲男人电影天堂| 欧美精品在线观看播放| 美国欧美日韩国产在线播放| 久久中文娱乐网| 99re热视频精品| 天天亚洲美女在线视频| 精品国产伦一区二区三区观看方式| 国产精品资源在线看| 亚洲啪啪综合av一区二区三区| 欧洲av在线精品| 久久精工是国产品牌吗| 欧美激情综合五月色丁香小说| 色婷婷精品久久二区二区蜜臀av| 亚洲午夜一区二区| 精品美女在线播放| 91啪亚洲精品|