aboutsummaryrefslogtreecommitdiffstats
path: root/etc.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-01-22 16:10:27 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-01-22 16:10:27 +0000
commitb8b4edb15b7c1eca41c6272a197b37574d5c8238 (patch)
tree6b5680ba64aacb350b972e377e883c37e32909cf /etc.c
parent[w3m-dev 03675] x-face (diff)
downloadw3m-b8b4edb15b7c1eca41c6272a197b37574d5c8238.tar.gz
w3m-b8b4edb15b7c1eca41c6272a197b37574d5c8238.zip
[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 <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r--etc.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/etc.c b/etc.c
index e7606aa..142ce74 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.52 2003/01/17 17:06:57 ukai Exp $ */
+/* $Id: etc.c,v 1.53 2003/01/22 16:10:28 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -1339,6 +1339,58 @@ setup_child(int child, int i, int f)
fmInitialized = FALSE;
}
+pid_t
+open_pipe_rw(FILE **fr, FILE **fw)
+{
+ int fdr[2];
+ int fdw[2];
+ pid_t pid;
+
+ if (fr && pipe(fdr) < 0)
+ goto err0;
+ if (fw && pipe(fdw) < 0)
+ goto err1;
+
+ flush_tty();
+ pid = fork();
+ if (pid < 0)
+ goto err2;
+ if (pid == 0) {
+ /* child */
+ if (fr) {
+ close(fdr[0]);
+ dup2(fdr[1], 1);
+ }
+ if (fw) {
+ close(fdw[1]);
+ dup2(fdw[0], 0);
+ }
+ }
+ else {
+ if (fr) {
+ close(fdr[1]);
+ *fr = fdopen(fdr[0], "r");
+ }
+ if (fw) {
+ close(fdw[0]);
+ *fw = fdopen(fdw[1], "w");
+ }
+ }
+ return pid;
+ err2:
+ if (fw) {
+ close(fdw[0]);
+ close(fdw[1]);
+ }
+ err1:
+ if (fr) {
+ close(fdr[0]);
+ close(fdr[1]);
+ }
+ err0:
+ return (pid_t) -1;
+}
+
void
myExec(char *command)
{