aboutsummaryrefslogtreecommitdiffstats
path: root/fbi.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2007-12-03 10:06:23 +0000
committerkraxel <kraxel>2007-12-03 10:06:23 +0000
commit2ce155bd0c6da70fdec714c3b07cffb3b05125ba (patch)
tree47e0041f2b447fddab51d84baee6fb5aa87de5b2 /fbi.c
parentfa5ab4916117a63fc0ec585aca9b6a08a0df9192 (diff)
downloadfbida-2ce155bd0c6da70fdec714c3b07cffb3b05125ba.tar.gz
kill popen() call
Diffstat (limited to 'fbi.c')
-rw-r--r--fbi.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/fbi.c b/fbi.c
index 052c5b7..f54a1fb 100644
--- a/fbi.c
+++ b/fbi.c
@@ -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 */