Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PNAME "megapipe"
- typedef struct{
- char * mail;
- char * pass;
- } ultimatestruct;
- void sigint(int signum) {
- char option[2];
- printf("\n ^C pressed. Do you want to abort? ");
- scanf("%1s", option);
- if (option[0] == 'y') {
- printf("Ok, bye bye!\n");
- exit(0);
- }
- }
- void main (){
- // Opens the pipe for writing
- // Redirects SIGINT to sigint()
- signal(SIGINT, sigint);
- int fd;
- ultimatestruct x;
- if ((fd=open(PNAME, O_WRONLY)) < 0)
- {
- perror("Cannot open pipe for writing: ");
- exit(0);
- }
- write(fd,&x,sizeof(ultimatestruct));
- }
Add Comment
Please, Sign In to add comment