Design and Develop a program to copy standard i/p to standard o/p using asynchronous i/o.
AIM:
Design and Develop a program to copy standard i/p to standard o/p using asynchronous i/o.
Program:
#include<signal.h> #include<fcntl.h> #define BUFFSIZE 4096 int sigflag; main() { int n; char buff [BUFFSIZE]; int sigio_func(); signal (SIGIO,sigio_func(); if (fcntl(0,F_SETDWN,getpid())<0) err-sys(“F_SETDWN,error”); if (fcntl(0,F_SETFL,FANC)<0) err-sys(“F_SETFL FASYNC,error”); for(;;)(sigblock(sigmask SIGIO)); while(sigflag==0) sigpause 10)/* wait for a signal*/ if(write(1,BUFF,N)!=N) err_sys(“write error”); } else if(n<0) err_sys(“read error”); else if(n==0) exit 0; /*EOF*/ sig flag=0;/*turn off one flag*/ sigetmask(0);/* and receivable signal*/ } int sigio func() { sigflag=1;/* just set flag and return */ }
Output:
Student@ubuntu:~$ gcc –o stadd.out stadd.c Student@ubuntu:~$ ./stadd.out I/O possible
-
UpdatedOct 23, 2014
-
Views2,447
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.