I am using kill function to kill a process. However, its returning -1 and perror shows “Invalid argument”. Reading the manual of kill, it says this error occurs if wrong signal value is provided. I am passing -9 or SIGKILL, like this kill( SIGKILL, pid ).
Then why is it giving invalid argument error. Note that the process who is calling the kill function is the child of the process that we are trying to kill.
killtakes its arguments the other way around. From the man page:Since you’re passing the PID in place of the signal number and vice-versa, it’s pretty likely that at least one of them will be an invalid argument as
perroris telling you.