- 博客(9)
- 收藏
- 关注
原创 wait获取子进程退出状态 WIFEXITED和WIFSIGNALED用法
可以使用wait函数传出参数status来保存进程的退出状态。常用宏函数分为日如下几组: 1、 WIFEXITED(status) 若此值为非0 表明进程正常结束。 若上宏为真,此时可通过WEXITSTATUS(status)获取进程退出状态(exit时参数) 示例: if(WIFEXITED(status)){ printf("退出值为 %d\n",
2016-12-20 22:08:24 34505
转载 execl()函数与execlp()函数
转自:http://www.jb51.net/article/71734.htmexecl()函数:执行文件函数头文件:#include定义函数:intexecl(const char * path, const char * arg, ...);函数说明:execl()用来执行参数path字符串所代表的文件路径,接下来的参数代表执行该文件时传递过去的arg
2016-12-20 13:58:17 29216
原创 gdb调试 fork程序 设置跟踪
使用gdb调试的时候,gdb只能跟踪一个进程。 可以在fork函数调用之前,通过指令设置gdb调试工具跟踪父进程或子进程。默认情况下gdb是跟踪父进程的。 set follow-fork-mode child命令设置gdb在fork之后跟踪子进程。set follow-fork-mode parent设置跟踪父进程。 注意:一定要在fork函数调用之前设置。
2016-12-20 10:45:50 9181
原创 Linux操作环境变量 getenv函数、setenv函数、unsetenv函数使用
1、getenv函数获取环境变量的值man 3 getenv #include char *getenv(const char*name); DESCRIPTION The getenv() function searches the environment list to find theenvironment variable na
2016-12-19 15:48:52 21782
原创 Linux系统environ环境变量 打印当前进程环境变量信息
在终端通过man 7 environ获取环境变量的相关信息:NAME environ - user environmentSYNOPSIS extern char **environ;DESCRIPTION The variable environ points to an array of pointers to strings ca
2016-12-19 14:59:35 2939
原创 gcc -D选项 编译时添加宏定义
程序实例:#include #include int main(int argc, char* argv[]){ #ifdef DEBUG printf("gcc 的-D 选项测试\n");#endif return 0;}直接编译运行不会有任何结果:yu@ubuntu:~/cplusplus/gcc$ gcc debugtest.c -o debugt
2016-12-19 10:59:11 23997
原创 access函数 权限测试
#include int access(const char *pathname, int mode);成功返回0失败返回-1R_OK(可读)、W_OK(可写)、X_OK(可执行)具体示例如下:#include #include #include int main(int argc, char* argv[]){ i
2016-12-16 14:39:29 766
转载 stat,lstat,fstat三者的区别
int stat(const char *path, struct stat *buf);int lstat(const char *path, struct stat *buf);int fstat(int filedes, struct stat *buf);转自:http://blog.csdn.net/hnlyyk/article/details/50826712
2016-12-16 14:16:08 1301
原创 stat函数及ls功能
stat filename 查看文件信息stat函数#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>int stat(const char *pathname, struct stat *buf);ls -l filename 功能的实现:#include <sys/types.h>#include <sys/sta
2016-12-16 14:03:57 2335
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人