Question - Explain the kill() system call and its return values?
Answer -
kill() system call sends signals to any process which further takes suitable action according to the signal. It takes two arguments, first is PID, to which you want to send a signal and the signal you want to send is second. This method returns the following return values:
- 0 - means that the process exists with the given PID and the system allows sending signals to it.
- -1 and errno==ESRCH - means that the process/process group with specified PID does not exist
- -1 and errno==EPERM - means that the sender has no permission to send a signal to the target process.
- EINVAL - means an invalid signal was specified.