linux系统调用函数-C语言
程序员文章站
2024-03-23 14:16:34
...
一、getpid
1.1 函数以及类似函数
getpid:返回当前进程标识,许多程序利用取到的此值来建立临时文件,以避免临时文件相同带来的问题。
getppid:返回父进程标识,(This will be either the ID of the process that created this
process using fork(), or, if that process has already terminated, the
ID of the process to which this process has been reparented (either
init(1) or a “subreaper” process defined via the prctl(2)
PR_SET_CHILD_SUBREAPER operation).)
1.2 用法
#include <sys/types.h>
#include <unistd.h>
pid_t getpid(void);
pid_t getppid(void);
1.3 报错
这个函数永远不会报错