I'm new to c, and this code confuses me:
pid_t getpid(void)
if what follows the type identifier pid_tis a variable (It's a variable declaration), but instead it's a function call getpid(), I don't know what why this function call is used.
You're right that pid_t is a type identifier, but it's not a variable. pid_t is the return type of the function getpid().
Every function in C has a return type. Functions are declared like this:
returntype functionName(arguments)
For example, int main(int argc, const char * argv[]) returns an int and takes two arguments.
pid_t getpid(void)
this means the function named getpid doesn't take any parameters (as the argument list contains only void) and returns a value of type pid_t (so you were correct with the type specifier).
Any basic book/tutorial on C would give you this information, I recommend you work through some of this on your own to get the basics down.
This SO question might be helpful: The Definitive C Book Guide and List