Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/mman.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/wait.h>
- #include <sys/file.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <unistd.h>
- int main()
- {
- int descriptor = creat("tekst2.txt",0600);
- pid_t pid;
- flock(descriptor,LOCK_SH );
- pid = fork();
- if(pid == 0)
- {
- char string_2[] = "POTOMNY PISZE\n";
- sleep(3);
- lseek(descriptor,0,SEEK_SET);
- write(descriptor,(void *)string_2,sizeof(string_2)-1);
- _exit(0);
- }
- else
- {
- char string_1[] = "RODZIC PISZE\n";
- lseek(descriptor,0,SEEK_SET);
- write(descriptor,(void*)string_1,sizeof(string_1)-1);
- }
- close(descriptor);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement