Skip to main content

Posts

Plenty of Programs of UNIX

Hey Guys Check Out The Following Link of Plenty of Programs of UNIX Download & Enjoy The Stuff. Follow The Given Link Below  Download UNIX Programs Bunch Here

Write programs to demonstrate communication between two processes. First process while send content of file to second process. Second process displays content by changing case.

#include #include #include main(int agrc,char *argv[]) {     int fd[2],pid,n,f,ch;     char buffer[2048],*cha;     if(pipe(fd)==-1)     {         printf(" problem to create the pipe \n ");         exit(0);     }     else     {         pid=fork();         if(pid!=0)         {             close(fd[0]);             f = open("hardik",O_RDONLY);             while((n = read(f,buffer,2048)) > 0)             {                 write(fd[1],buffer,n);             }             close(fd[1]);         }         else         {...

Write a program to create a pipe and share between parent and child process. Parent writes content to pipe from the file and child reads the content and display number of characters.

#include #include #include #include main(int agrc,char *argv[]) {     int fd[2],pid,n,f,ch;     char buffer[2048];     if(pipe(fd)==-1)     {         printf(" problem to create the pipe \n ");         exit(0);     }     else     {         pid=fork();         if(pid!=0)         {             close(fd[0]);             f = open("hardik",O_RDONLY);             while((n = read(f,buffer,2048)) > 0)             {                 write(fd[1],buffer,n);             }             close(fd[1]);         }         else       ...

Write a program to execute ls command in child process. Parent process must wait for child termination.

#include #include #include main() {     int pid,w,Status;     printf("PRENT PROCESS PORTION  \n");     pid=fork();     if(pid==0)     {         printf("child process part \n ");         execl("/bin/ls","ls",0);     }     sleep(3);     w = wait(&Status);     printf("parent process after child execution \n "); }

Write a program to create a child process in which child process displays number of line sent by parent process.

#include #include #include #include #include main(int agrc,char *argv[]) {     int fd[2],pid,line=0,n;     char buffer[2048]="Milind Audichya\Dhruv Naik\Uzer Pathan\n",buffer2[1];     if(pipe(fd)==-1)     {         printf(" problem to create the pipe \n ");         exit(0);     }     else     {         pid=fork();         if(pid!=0)         {             printf("Perent Send Data To Chlid Data is:- %s ",buffer);             close(fd[0]);             write(fd[1],buffer,strlen(buffer));             close(fd[1]);         }         else         {             close(fd[1]);     ...

Write a program to create three child process. The parent process send the signal to terminate all these child processes.

#include #include main() {     int pid[3],status,i;     for(i=0;i     {     pid[i]=fork();     printf("\n new created child process value is :%d",pid[i]);     }     for(i=0;i     {         if(pid[i])         {             printf("for terminate the process  \n");             kill(pid[i],9);             printf("termination of the child process :%d \n ",pid[i]);         }     } } }