The process Environment for UNIX advanced programming

Source: Internet
Author: User


Process: Running a program
Threads: Functions that run

1.main ()
Startup routines
Exit (int main (argc, argv));
2. Process termination
The process terminates normally:
<1>main () return;
<2>exit (3);
1) Call Termination handler
2) Standard IO cleanup program
<3>_exit (2) _exit (2);
<4> last thread called Pthread_exit (3);
<5> the last thread returned from the startup routine
Abnormal termination:
<1>abort (3);
<2> thread response to cancellation
<3> Signal Termination

Atexit (3);
hook function
The order in which the registration functions are executed is the opposite of the order in which they are registered
Execution condition: the main () function calls return, or exit (3) is called at any location;

3. Environment variables and environment tables
"Name=value"
Getenv (3);
Setenv (3);

4. Parsing of command-line arguments
int getopt (int argc, char **argv, const char *optstring);
ARGC and argv are the two parameters of the main () function
Optstring There are rules:
"-ab:c::"
<1> start with "-" to resolve non-option parameters, return 1
<2> "a" parse option parameter "-a", return ' a '
<3> "B:" Parse with parameter option "-B argument", return ' B. ', Optarg point to argument
<4> "C::" Parse the option "-cargument" with parameters, return ' C ', Optarg point to argument, enter no parameters optarg==null

Homework:
#./a.out-y 4-m-d-h24filename

Strftime (3);

Getopt_long (3);
Ability to parse long format options
--help
--help Arg
--help=arg

Ls-l/etc/passed
GCC Hello.c-wall
TAR-CVF Bao.tar file1 file2 file3
-L: Option parameter
/ETC/PASSWD: Non-option parameter
-w: Option parameter with parameters all
-F: Option parameter with parameters Bao.tar

5.C Storage Distribution Layout

6. Shared libraries
Manual Loading Library
Dlopen ();
Dlsym ();
Dlclose ();

7.SETJMP () and longjmp ()
SETJMP (), longjmp () implements a jump between functions
Goto implementation jumps inside a function

8.getrlimit (2) and Setrlimit (2)

The process Environment for UNIX advanced programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.