## kill ##
传送信号给指定的进程
### 相关函数 ###
raise,signal
### 表头文件 ###
```
#include<sys/types.h>
#include<signal.h>
```
### 定义函数 ###
```
int kill(pid_t pid, int sig);
```
### 函数说明 ###
kill()可以用来送参数sig指定的信号给参数pid指定的进程。参数pid有几种情况:
pid>0 将信号传给进程识别码为pid 的进程。
pid=0 将信号传给和目前进程相同进程组的所有进程
pid=-1 将信号广播传送给系统内所有的进程
pid<0 将信号传给进程组识别码为pid绝对值的所有进程
参数sig代表的信号编号可参考附录D
### 返回值 ###
执行成功则返回0,如果有错误则返回-1。
### 错误代码 ###
EINVAL 参数sig 不合法
ESRCH 参数pid 所指定的进程或进程组不存在
EPERM 权限不够无法传送信号给指定进程
### 范例 ###
```
#include<unistd.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>
main()
{
pid_t pid;
int status;
if(!(pid= fork())){
printf(“Hi I am child process!\n”);
sleep(10);
return;
}
else{
printf(“send signal to child process (%d) \n”,pid);
sleep(1);
kill(pid ,SIGABRT);
wait(&status);
if(WIFSIGNALED(status))
printf(“chile process receive signal %d\n”,WTERMSIG(status));
}
}
```
### 执行 ###
```
sen signal to child process(3170)
Hi I am child process!
child process receive signal 6
```
- 字符测试篇
- isalnum
- isalpha
- isascii
- iscntrl
- isdigit
- isgraphis
- islower
- isprint
- isspace
- ispunct
- isupper
- isxdigit
- 字符串转换篇
- atof
- atoi
- atol
- gcvt
- strtod
- strtol
- strtoul
- toascii
- tolower
- toupper
- 内存控制篇
- calloc
- free
- getpagesize
- malloc
- mmap
- munmap
- 日期时间篇
- asctime
- ctime
- gettimeofday
- gmtime
- localtime
- mktime
- settimeofday
- time
- 内存及字符串操作篇
- bcmp
- bcopy
- bzero
- index
- memccpy
- memchr
- memcmp
- memcpy
- memmove
- memset
- rindex
- strcasecmp
- strcat
- strchr
- strcmp
- strcoll
- strcpy
- strcspn
- strdup
- strlen
- strncasecmp
- strncat
- strncpy
- strpbrk
- strrchr
- strspn
- strstr
- strtok
- 常用数学函数篇
- abs
- acos
- asin
- atan
- atan2
- ceil
- cos
- cosh
- exp
- frexp
- ldexp
- log
- log10
- pow
- sin
- sinh
- sqrt
- tan
- tanh
- 用户组篇
- endgrent
- endpwent
- endutent
- fgetgrent
- fgetpwent
- getegid
- geteuid
- getgid
- getgrent
- getgrgid
- getgrnam
- getgroups
- getpw
- getpwent
- getpwnam
- getpwuid
- getuid
- getutent
- getutid
- getutline
- initgroups
- pututline
- seteuid
- setfsgid
- setfsuid
- setgid
- setgrent
- setgroups
- setpwent
- setregid
- setreuid
- setuid
- setutent
- utmpname
- 数据结构及算法篇
- crypt
- bsearch
- lfind
- lsearch
- qsort
- rand
- srand
- 文件操作篇
- close
- creat
- dup
- dup2
- fcntl
- flock
- fsync
- lseek
- mkstemp
- open
- read
- sync
- write
- 文件内容操作篇
- clearerr
- fclose
- fdopen
- feof
- fflush
- fgetc
- fgets
- fileno
- fopen
- fputc
- fputs
- fread
- freopen
- fseek
- ftell
- fwrite
- getc
- getchar
- gets
- mktemp
- putc
- putchar
- rewind
- setbuf
- setbuffer
- setlinebuf
- setvbuf
- ungetc
- 进程操作篇
- atexit
- execl
- execlp
- execv
- execve
- execvp
- exit
- _exit
- vfork
- getpgid
- getpgrp
- getpid
- getppid
- getpriority
- nice
- on_exit
- setpgid
- setpgrp
- setpriority
- system
- wait
- waitpid
- 格式化输入输出篇
- fprintf
- fscanf
- printf
- scanf
- sprintf
- sscanf
- vfprintf
- vfscanf
- vprintf
- vscanf
- vsprintf
- vsscanf
- 文件权限控制篇
- access
- alphasort
- chdir
- chmod
- chown
- chroot
- closedir
- fchdir
- fchmod
- fchown
- fstat
- ftruncate
- getcwd
- link
- lstat
- opendir
- readdir
- readlink
- remove
- rename
- rewinddir
- seekdir
- stat
- symlink
- telldir
- truncate
- umask
- unlink
- utime
- utimes
- 信号处理篇
- alarm
- kill
- pause
- sigaction
- sigaddset
- sigdelset
- sigemptyset
- sigfillset
- sigismember
- signal
- sigpending
- sigprocmask
- sleep
- ferror
- perror
- strerror
- mkfifo
- pclose
- pipe
- popen
- 接口处理篇
- accept
- bind
- connect
- endprotoent
- endservent
- getsockopt
- htonl
- htons
- inet_addr
- inet_aton
- inet_ntoa
- listen
- ntohl
- ntohs
- recv
- recvfrom
- recvmsg
- send
- sendmsg
- sendto
- setprotoent
- setservent
- setsockopt
- shutdown
- socket
- 环境变量篇
- getenv
- putenv
- setenv
- 终端控制篇
- getopt
- isatty
- select
- ttyname