EMBEDDED/SYSTEM Proc
[Signal] kill() 관련예제
몰라욧
2012. 7. 13. 16:28
a.out
#include <stdio.h>
#include <unistd.h>
main()
{
/* 무한 반복 */
while(1) {
printf("running\n");
sleep(5);
}
}
b.out
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
main(int argc, char *argv[])
{
/* argv[1]번 프로세스에 SIGKILL 시그널 보냄 */
kill(atoi(argv[1]), SIGKILL); /* argv[1]은 문자열이므로 정수로 변환 */
}
[localhost@local]#a.out &
[1] 2000...
running
[localhost@local]#b.out 2000
[1]+ killed