Kill command in c-programming [duplicate]
Possible Duplicate:
Unable to 开发者_开发问答understand the “Kill” program of linux
Hi All, Can anyone explain me how this program works. Please explain what each line do.
#include<stdio.h>
#include<sys/types.h>
#include<signal.h>
int main(int argc, char **argv)
{
if (argc < 2)
{
printf("usage: ./kill PID");
return -1;
}
kill(atoi(argv[1]), SIGKILL);
return 0;
}
The line kill(atoi(argv[1]), SIGKILL);
sends a SIGKILL signal to the process with the specified ID; this should cause it to terminate. The atoi(argv[1])
part converts the string from the command-line parameters into an integer.
For the rest, I recommend picking up a beginner's guide to C.
精彩评论