Linux pid_t定义



Linux pid_t定义
 
   在创建进程过程中经常会用到定义进程号的数据类型:pid_t,大家都知道是int型,
下面是我在Linux C中头文件中找到这个定义的过程:
  www.2cto.com  
1,/usr/include/sys/types.h中有如下定义
 
#include <bits/types.h> 
...... 
#ifndef __pid_t_defined 
typedef __pid_t pid_t; 
# define __pid_t_defined 
#endif 
可以看到pid_t 其实就是__pid_t类型。
 
2.在/usr/include/bits/types.h中可以看到这样的定义   www.2cto.com  
#include <bits/typesizes.h> 
#if __WORDSIZE == 32 
...... 
# define __STD_TYPE        __extension__ typedef 
#elif __WORDSIZE == 64 
...... 
#endif 
...... 
__STD_TYPE __PID_T_TYPE __pid_t;    /* Type of process identifications.  */ 
可以看出__pid_t 有被定义为 __extension__ typedef  __PID_T_TYPE类型的。 
 
3.在文件/usr/include/bits/typesizes.h中可以看到这样的定义(这个文件中没有包含任何的头文件): 
#define __PID_T_TYPE        __S32_TYPE 
可以看出__PID_T_TYPE有被定义为__S32_TYPE这种类型。 
 
4.在文件/usr/include/bits/types.h中我们终于找到了这样的定义: 
#define    __S32_TYPE        int 
由此我们终于找到了pid_t的真实定义:实际他就是  int  类型的。
 

相关内容

    暂无相关文章