UNIX Environment Advanced Programming Learning Note (iv): Process environment

Source: Internet
Author: User

1 exit function and _exit function

#include <stdlib.h>void exit (int  status)void _exit (int status)

The difference between these two functions is that the exit function performs cleanup before entering the kernel (cleanup I/O buffering), and the_exit function goes directly into the kernel

2 atexit function, register function, execute at exit

int atexit (void (* func) (void));

The functions that are registered are called termination handlers, which are called in the reverse order of registration, and are called multiple times if a function is registered multiple times.

3 malloc function and calloc function

#include <stdlib.h>void * malloc (size_t size)void* CALLOC (size_t nobj, size_t Size

malloc allocates space according to number of bytes,calloc allocates space according to number of objects

4 getenv, get environment variable

#include <stdlib.h>Char* getenv (constChar* name)

Get value by name

5 putenv,setenv,unsetenv function

int putenv (char* str)int setenv (constcharconst  charint  rewrite)int unsetenv (char* name)

Putenv takes the "Name=value" form of the string as a parameter, adds it to the environment,

Unsetenv Delete The term "name"

UNIX Environment Advanced Programming Learning Note (iv): Process environment

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.