Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by resolution on 20.11.17.
- //
- #include <stdio.h>
- #include <errno.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <string.h>
- #define MAXBUFF 100
- int main(int argc, char* argv[])
- {
- int fd[2];
- int pid;
- char buffor[] = "pepethefrog.png";
- char out[MAXBUFF];
- int licz;
- if(pipe(fd) == -1 )
- {
- fprintf (stderr, "Nie udalo sie stowrzyc potoku: %s", strerror (errno));
- exit(2);
- }
- if((pid = fork()) == -1)
- {
- fprintf (stderr, "Nie udalo sie sforkowac: %s", strerror (errno));
- exit(1);
- }
- if(pid == 0) // potomek
- {
- write(fd[1], buffor, (strlen(buffor) + 1 ));
- dup2(0, fd[0]);
- //execlp("display", "display", NULL);
- execlp("eog", "eog", NULL);
- }
- else // rodzic
- {
- close(fd[1]);
- licz = read(fd[0], out, sizeof(out));
- printf("Mam: %s", out);
- //execlp("eog", "eog", NULL);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement