Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- /*
- * amocana:
- * # mshobelma pipe-shi chaweros 'str';
- * # shvilma es 'str' pipe-dan waikitxos;
- * # shvilma chaweros es 'str' failshi;
- * # amis shemdeg mshobelma daakompiliros da gaushvas!
- */
- int main()
- {
- char str[] = "ragaca kodi!...";
- char str2[N]; // N vigulisxmot rom vicit da aris str-shi simboloebis raodenoba!
- int pr, fd[2], status, fd;
- if (pipe(fd) == -1) exit(-1);
- pr = fork();
- if (pr == -1) exit(-1);
- if (pr != 0) // mshobeli:
- {
- // # mshibelma chaweros str kodi pipeshi!
- if (write(fd[1], str, sizeof(str)) != sizeof(str)) exit(-1);
- wait(&status);
- // chaweris shemdeg unda davacompilirot da mere gavushvat!
- execl("usr/bin/gcc", "gcc", "test.c", "-o", "test.out");
- execl("test.out","./test.out", NULL);
- }
- else // shvili:
- {
- // # shvilma pipedan waikitxos da chaweros failshi
- if (read(fd[0], str2, sizeof(str2)) != sizeof(str2)) exit(-1);
- (void) umask(0);
- fd = open("test.c", O_WRONLY | O_CREAT, 0756);
- if (fd == -1) exit(-1);
- if (write(fd, str2, sizeof(str2)) != sizeof(str2)) exit(-1);
- // vsio sheiqmna faili da chaiwera!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement