Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/wait.h>
- int main( int argc, char *argv[] ){
- FILE *fptr;
- pid_t pid;
- fptr = fopen("Shared File.txt", "a");
- pid = fork();
- if( pid > 0 ){ // parent process
- int counter = 0;
- while( counter < 10 ){
- fprintf(fptr, "a");
- ++counter;
- }
- wait(NULL);
- }
- else{
- int counter = 0;
- while( counter < 5 ){
- fprintf(fptr, "b");
- ++counter;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment