标签:
C编译器(gcc)——>连接编辑器— (设置起始地址:启动例程)—>可执行程序文件—(启动例程)—>内核(命令行参数、环境变量值)
——>main()—(大多数)—>exit()——>_exit()【or _Exit()】
#include <stdlib.h> void exit(int status); void _Exit(int status); #include <unistd.h> void _exit(int status);
#include <stdlib.h> int atexit(void (*func)(void));
//return: success, 0; error, other.
#include <stdlib.h> void *malloc(size_t size); void *calloc(size_t nobj, size_t size); void *realloc(void *ptr, size_t newsize); //return: success, 非空;error, NULL. void free(void *ptr);
#include <stdlib.h> char *getenv(const char *name); //return: 与 name 关联的指针,未找到则 NULL. int putenv(char *str); int setenv(const char *name, const char *value, int rewrite); int unsetenv(const char *name); //return: success, 0; error, 非0.
#include <setjmp.h> int setjmp(jmp_buf env); //return: 直接返回,0; 从 longjmp 调用返回则 非0. void longjmp(jmp_buf env, int val);
#include <sys/resource.h> int getrlimit(int resource, struct rlimit *rlptr); int setrlimit(int resource, const struct rlimit *rlptr); //return: success, 0; error, 非0.
#include <pthread.h>
int pthread_equal (pthread_t tid1, pthread_t tid2); //return: S, 0; E, 非0.
pthread_t pthread_self (void); // return ID.
int pthread_create (pthread_t *restrict tidp, const pthread_attr_t *restrict attr,
void *(*start_rtn)(void), void *restrict arg);
//return: S, 0; E, 错误编号.
void pthread_exit(void *rval_ptr);
int pthread_join(pthread_t thread, void **rval_ptr); //return: S, 0; E, 错误编号.
int pthread_cancel(pthread_t tid); //return: S, 0; E, 错误编号.
void pthread_cleanup_push(void (*rtn)(void *), void *arg);
void pthread_cleanup_pop(int execute);
int pthread_detach (pthread_t tid); //return: S, 0; E, 错误编号.
int pthread_mutex_init (pthread_mutex_t *restrict mutex,
const pthread_mutexattr_t *restrict attr);
int pthread_mutex_destroy (pthread_mutex_t *mutex);
//return: S, 0; E, 错误编号.
int pthread_mutex_lock (pthread_mutex_t *mutex);
int pthread_mutex_trylock (pthread_mutex_t *mutex);
int pthread_mutex_unlock (pthread_mutex_t *mutex);
//return: S, 0; E, 错误编号.
int pthread_rwlock_init (pthread_rwlock_t *restrict rwlock,
const pthread_rwlockattr_t *restrict attr);
int pthread_rwlock_destroy (pthread_rwlock_t *mutex);
//return: S, 0; E, 错误编号.
int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock);
int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock);
int pthread_rwlock_unlock (pthread_rwlock_t *rwlock);
//return: S, 0; E, 错误编号.
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
//return: S, 0; E, 错误编号.
int pthread_cond_init (pthread_cond_t *restrict cond,
const pthread_condattr_t *restrict attr);
int pthread_cond_destroy (pthread_cond_t *cond);
//return: S, 0; E, 错误编号.
int pthread_cond_wait (pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
int pthread_cond_timedwait (pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict timeout);
//return: S, 0; E, 错误编号.
int pthread_cond_signal (pthread_cond_t *cond);
int pthread_cond_broadcast (pthread_cond_t *cond);
//return: S, 0; E, 错误编号.
标签:
原文地址:http://www.cnblogs.com/liyangguang1988/p/5444946.html