I\'m trying to return an integer value from a child process.
However, if I use exit(1) i get 256 as the output. exit(-1)
The exit code is a 16-bit value.
The high-order 8 bits are the exit code from exit().
The low-order 8 bits are zero if the process exited normally, or encode the signal number that killed the process, and whether it dumped core or not (and if it was signalled, the high-order bits are zero).
Check out the header and the documentation for the waitpid() system call to see how to get the correct values with WIFEXITED and WEXITSTATUS.