6

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);

2 Answers2

8

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.

babon
  • 3,615
  • 2
  • 20
  • 20
4

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.

Majid Roustaei
  • 1,556
  • 1
  • 20
  • 39