Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <signal.h>
- int getPidd();
- int main(int argc, char* argv[])
- {
- printf("\tCommand Center\n");
- if(argc!=1)
- {
- printf("Program is working without parameters.\n");
- exit(1);
- }
- int target_pid;
- target_pid=getPidd();
- switch(kill(target_pid,SIGRTMIN+6))
- {
- case 0:
- printf("Signal send succesfully!\n");
- break;
- default:
- switch(errno)
- {
- case EINVAL:
- printf("The value of the sig argument is an invalid or unsupported signal number\n");
- break;
- case EPERM:
- printf("The process does not have permission to send the signal to any receiving process\n");
- break;
- case ERSCH:
- printf("No process or process group can be found corresponding to that specified by pid\n");
- break;
- }
- break;
- }
- }
- int getPidd()
- {
- char target_pid[6];
- char *endint;
- int pid;
- while(1)
- {
- printf("Provide a PID:\n");
- scanf("%6s",target_pid);
- pid=strtol(target_pid,&endint,10);
- if(*endint || pid<=2 || pid==getpid())
- {
- printf("Incorrect PID!\n");
- continue;
- }
- else
- {
- printf("PID: %d\n",pid);
- break;
- }
- }
- return pid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement