Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <dirent.h>
- /*
- Student: Bivolaru Alexandru
- Grupa: 30225
- */
- int counter()
- {
- pid_t current;
- int status;
- int fd = open("Fisier.txt",O_RDWR);
- if(fd == -1)
- {
- printf("fisierul nu s-a putut deschide!");
- exit(1);
- }
- for(int i = 1; i <= 10; i++)
- {
- current = fork();
- if(current > 0)
- {
- waitpid(current,&status,0);
- char c;
- if(write(fd,&c,sizeof(char)) < 0)
- {
- printf("Nu s-a putut scrie in fisier!");
- exit(1);
- }
- }
- }
- long procese = lseek(fd,0,SEEK_END);
- return procese;
- }
- int main()
- {
- printf("%d\n",counter());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement