Guest User

Untitled

a guest
Jan 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #define PNAME "megapipe"
  2.  
  3. typedef struct{
  4.     char * mail;
  5.     char * pass;
  6.   } ultimatestruct;
  7.  
  8. void sigint(int signum) {
  9.   char option[2];
  10.   printf("\n ^C pressed. Do you want to abort? ");
  11.  
  12.   scanf("%1s", option);
  13.   if (option[0] == 'y') {
  14.     printf("Ok, bye bye!\n");
  15.     exit(0);
  16.   }
  17. }
  18.  
  19. void main (){
  20.     // Opens the pipe for writing
  21.  
  22.   // Redirects SIGINT to sigint()
  23.   signal(SIGINT, sigint);
  24.  
  25.   int fd;
  26.   ultimatestruct x;
  27.  
  28.   if ((fd=open(PNAME, O_WRONLY)) < 0)
  29.   {
  30.     perror("Cannot open pipe for writing: ");
  31.     exit(0);
  32.   }
  33.  
  34.   write(fd,&x,sizeof(ultimatestruct));
  35.  
  36.   }
Add Comment
Please, Sign In to add comment