getppid.c

来自「这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易」· C语言 代码 · 共 24 行

C
24
字号
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdlib.h>#include <unistd.h>#include <errno.h>#include "sys9.h"pid_tgetppid(void){	int n, f;	char ppidbuf[15];	f = open("#c/ppid", 0);	n = read(f, ppidbuf, sizeof ppidbuf);	if(n < 0)		errno = EINVAL;	else		n = atoi(ppidbuf);	close(f);	return n;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?