diff options
author | kraxel <kraxel> | 2007-12-03 10:06:23 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2007-12-03 10:06:23 +0000 |
commit | 2ce155bd0c6da70fdec714c3b07cffb3b05125ba (patch) | |
tree | 47e0041f2b447fddab51d84baee6fb5aa87de5b2 /fbi.c | |
parent | fa5ab4916117a63fc0ec585aca9b6a08a0df9192 (diff) | |
download | fbida-2ce155bd0c6da70fdec714c3b07cffb3b05125ba.tar.gz |
kill popen() call
Diffstat (limited to 'fbi.c')
-rw-r--r-- | fbi.c | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -666,11 +666,29 @@ read_image(char *filename) } if (NULL == loader) { /* no loader found, try to use ImageMagick's convert */ - snprintf(command,sizeof(command), - "convert -depth 8 \"%s\" ppm:-",filename); - if (NULL == (fp = popen(command,"r"))) + int p[2]; + + if (0 != pipe(p)) return NULL; - loader = &ppm_loader; + switch (fork()) { + case -1: /* error */ + perror("fork"); + close(p[0]); + close(p[1]); + return(NULL); + case 0: /* child */ + dup2(p[1], 1 /* stdout */); + close(p[0]); + close(p[1]); + execl("convert", "convert", "-depth", "8", filename, "ppm:-", NULL); + exit(1); + default: /* parent */ + close(p[1]); + fp = fdopen(p[0], "r"); + if (NULL == (fp = popen(command,"r"))) + return NULL; + loader = &ppm_loader; + } } /* load image */ |