Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- #include <sys/types.h>
- #include <fcntl.h>
- void HandlerSigHUP(int signal);
- char prompt[100];
- int rdp;
- int main(int argc , char *argv[]){
- int fp,rd,i=0;
- char buffer[100];
- printf("%d\n",getpid());
- fp=open("shell.conf",O_RDONLY,0666);
- rdp = read(fp,prompt,sizeof(prompt));
- close(fp);
- signal(SIGHUP,HandlerSigHUP);
- while(i==0){
- write(0,prompt,rdp-1);
- rd=read(0,buffer,sizeof(buffer));
- write(0,buffer,rd);
- }
- return 0;
- }
- void HandlerSigHUP(int signal){
- int fp;
- printf("dfj\n");
- if(signal == SIGHUP){
- fp=open("shell.conf",O_RDONLY,0666);
- rdp=read(fp,prompt,sizeof(prompt));
- write(0,prompt,rdp-1);
- close(fp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment