随笔分类 - Linux进程
摘要:/************proto.h********************/ #ifndef __PROTO_H__#define __PROTO_H__ #define FORMAT "%ld\n"#define MINIDLEPROCNUM 5#define MAXIDLEPROCNUM
阅读全文
摘要:pid_t setsid(void); void openlog(const char *ident, int option, int facility); void syslog(int priority, const char *format, ...); void closelog(void)
阅读全文
摘要:简易mysh示例:mysh.c #include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/wait.h>#include <glob.h>#include <string.h
阅读全文
摘要:1、进程标识符 PID pid_t //进程数据类型 ps //ps及相关命令 ps axf ps axm ps ax -L pid_t getpid(void); //获取当前进程PID pid_t getppid(void); //获取父进程PID 2、进程的产生 pid_t fork(void
阅读全文
摘要:环境变量 export //输出所有环境变量 extern char **environ; char *getenv(const char *name); //获取某个环境变量 int setenv(const char *name, const char *value, int overwrite
阅读全文
摘要:#include <unistd.h> int getopt(int argc, char * const argv[],const char *optstring); //获取命令行参数 extern char *optarg; //参数选项(全局变量) extern int optind, op
阅读全文
摘要:正常终止 1、从main函数返回 2、调用exit 3、调用_exit或_Exit //出现不可预料的错误时调用 4、最后一个线程从启动例程返回 5、最后一个线程调用pthread_exit 异常终止 1、调用abort 2、接到一个信号并终止 3、最后一个线程对其取消请求作出相应 atexit()
阅读全文
摘要:系统时间获取 time_t time(time_t *tloc); //获取时间戳 struct tm *gmtime(const time_t *timep); //通过时间戳获取时间结构体 struct tm *gmtime_r(const time_t *timep, struct tm *r
阅读全文
摘要:密码校验: 1、通过UID或name获取用户信息(/etc/passwd) struct passwd *getpwnam(const char *name); struct passwd *getpwuid(uid_t uid); 2、通过gid或grname获取用户组信息(/etc/group)
阅读全文