Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference of pid_t and int in C [duplicate]

Tags:

c

types

process

what's the difference between pid_t datatype and int when getting process id? I saw something like:

pid_t getpid(void);

but whats the difference between it and

int getpid(void);
like image 747
amjad Avatar asked Dec 23 '22 03:12

amjad


2 Answers

Quoting from the libc manual:

The pid_t data type is a signed integer type which is capable of representing a process ID. In the GNU C Library, this is an int.

like image 93
babon Avatar answered Dec 31 '22 02:12

babon


data types that ends with "_t", are usually a defined type variable in C and C++ as an unwritten law. according to that law, "pid_t" is a data type which is defined somewhere else but "int" a standard type; so to know the differences you need to know how "pid_t" is defined.

like image 44
Majid Roustaei Avatar answered Dec 31 '22 00:12

Majid Roustaei