From b8b4edb15b7c1eca41c6272a197b37574d5c8238 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 22 Jan 2003 16:10:27 +0000 Subject: [w3m-dev 03676] cleanup for pipe * etc.c (open_pipe_rw): added * file.c (uncompress_stream): rewrite using open_pipe_rw * image.c (openImgdisplay): rewrite using open_pipe_rw * local.c (localcgi_popen_rw): deleted (localcgi_post): rewrite using open_pipe_rw * proto.h (open_pipe_rw): added * search.c (migemor): initialized to NULL (migemow): initialized to NULL (migemo_pid): initialized to 0 (open_migemo): rewrite using open_pipe_rw From: Hironori SAKAMOTO --- image.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index 62daccb..49ed6f0 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.26 2003/01/17 16:57:19 ukai Exp $ */ +/* $Id: image.c,v 1.27 2003/01/22 16:10:28 ukai Exp $ */ #include "fm.h" #include @@ -89,24 +89,12 @@ termImage() static int openImgdisplay() { - int fdr[2], fdw[2]; - char *cmd; - - if (pipe(fdr) < 0) - goto err0; - if (pipe(fdw) < 0) - goto err1; - - flush_tty(); - Imgdisplay_pid = fork(); + Imgdisplay_pid = open_pipe_rw(&Imgdisplay_rf, &Imgdisplay_wf); if (Imgdisplay_pid < 0) - goto err2; + goto err0; if (Imgdisplay_pid == 0) { /* child */ - close(fdr[0]); - close(fdw[1]); - dup2(fdw[0], 0); - dup2(fdr[1], 1); + char *cmd; setup_child(FALSE, 2, -1); set_environ("W3M_TTY", ttyname_tty()); if (!strchr(Imgdisplay, '/')) @@ -116,21 +104,9 @@ openImgdisplay() myExec(cmd); /* XXX: ifdef __EMX__, use start /f ? */ } - close(fdr[1]); - close(fdw[0]); - Imgdisplay_rf = fdopen(fdr[0], "r"); - Imgdisplay_wf = fdopen(fdw[1], "w"); activeImage = TRUE; return TRUE; - err2: - close(fdw[0]); - close(fdw[1]); - err1: - close(fdr[0]); - close(fdr[1]); err0: - Imgdisplay_rf = NULL; - Imgdisplay_wf = NULL; Imgdisplay_pid = 0; activeImage = FALSE; return FALSE; -- cgit v1.2.3