[w3m-dev 03679] Re: cleanup for pipe
* etc.c (open_pipe_rw): check stdin, stdout * file.c (uncompress_stream): rewrite From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2003-01-24 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||
|
||||
* [w3m-dev 03679] Re: cleanup for pipe
|
||||
* etc.c (open_pipe_rw): check stdin, stdout
|
||||
* file.c (uncompress_stream): rewrite
|
||||
|
||||
2003-01-23 Fumitoshi UKAI <ukai@debian.or.jp>
|
||||
|
||||
* [w3m-dev 03678] Re: config.param is clear when configure -help
|
||||
@@ -6715,4 +6721,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
||||
* release-0-2-1
|
||||
* import w3m-0.2.1
|
||||
|
||||
$Id: ChangeLog,v 1.705 2003/01/22 16:36:11 ukai Exp $
|
||||
$Id: ChangeLog,v 1.706 2003/01/23 15:59:24 ukai Exp $
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: etc.c,v 1.54 2003/01/22 16:11:03 ukai Exp $ */
|
||||
/* $Id: etc.c,v 1.55 2003/01/23 15:59:25 ukai Exp $ */
|
||||
#include "fm.h"
|
||||
#include <pwd.h>
|
||||
#include "myctype.h"
|
||||
@@ -1369,11 +1369,17 @@ open_pipe_rw(FILE ** fr, FILE ** fw)
|
||||
else {
|
||||
if (fr) {
|
||||
close(fdr[1]);
|
||||
*fr = fdopen(fdr[0], "r");
|
||||
if (*fr == stdin)
|
||||
dup2(fdr[0], 0);
|
||||
else
|
||||
*fr = fdopen(fdr[0], "r");
|
||||
}
|
||||
if (fw) {
|
||||
close(fdw[0]);
|
||||
*fw = fdopen(fdw[1], "w");
|
||||
if (*fw == stdout)
|
||||
dup2(fdw[1], 1);
|
||||
else
|
||||
*fw = fdopen(fdw[1], "w");
|
||||
}
|
||||
}
|
||||
return pid;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: file.c,v 1.200 2003/01/22 16:16:20 ukai Exp $ */
|
||||
/* $Id: file.c,v 1.201 2003/01/23 15:59:27 ukai Exp $ */
|
||||
#include "fm.h"
|
||||
#include <sys/types.h>
|
||||
#include "myctype.h"
|
||||
@@ -7749,6 +7749,7 @@ uncompress_stream(URLFile *uf, char **src)
|
||||
tmpf = tmpfname(TMPF_DFL, ext)->ptr;
|
||||
}
|
||||
|
||||
/* child1 -- stdout|f1=uf -> parent */
|
||||
pid1 = open_pipe_rw(&f1, NULL);
|
||||
if (pid1 < 0) {
|
||||
UFclose(uf);
|
||||
@@ -7757,31 +7758,36 @@ uncompress_stream(URLFile *uf, char **src)
|
||||
if (pid1 == 0) {
|
||||
/* child */
|
||||
pid_t pid2;
|
||||
FILE *f2;
|
||||
dup2(1, 2); /* stderr>&stdout */
|
||||
setup_child(TRUE, -1, UFfileno(uf));
|
||||
pid2 = open_pipe_rw(NULL, &f2);
|
||||
FILE *f2 = stdin;
|
||||
|
||||
/* uf -> child2 -- stdout|stdin -> child1 */
|
||||
pid2 = open_pipe_rw(&f2, NULL);
|
||||
if (pid2 < 0) {
|
||||
UFclose(uf);
|
||||
exit(1);
|
||||
}
|
||||
if (pid2 > 0) {
|
||||
if (pid2 == 0) {
|
||||
/* child2 */
|
||||
Str buf = Strnew_size(SAVE_BUF_SIZE);
|
||||
FILE *f = NULL;
|
||||
|
||||
setup_child(TRUE, 2, UFfileno(uf));
|
||||
if (tmpf)
|
||||
f = fopen(tmpf, "wb");
|
||||
while (UFread(uf, buf, SAVE_BUF_SIZE)) {
|
||||
if (Strfputs(buf, f2) < 0)
|
||||
if (Strfputs(buf, stdout) < 0)
|
||||
break;
|
||||
if (f)
|
||||
Strfputs(buf, f);
|
||||
}
|
||||
fclose(f2);
|
||||
UFclose(uf);
|
||||
if (f)
|
||||
fclose(f);
|
||||
exit(0);
|
||||
}
|
||||
/* child */
|
||||
/* child1 */
|
||||
dup2(1, 2); /* stderr>&stdout */
|
||||
setup_child(TRUE, -1, -1);
|
||||
execlp(expand_cmd, expand_name, NULL);
|
||||
exit(1);
|
||||
}
|
||||
@@ -7792,7 +7798,7 @@ uncompress_stream(URLFile *uf, char **src)
|
||||
uf->scheme = SCM_LOCAL;
|
||||
}
|
||||
UFhalfclose(uf);
|
||||
uf->stream = newFileStream(f1, (void (*)())fclose);
|
||||
uf->stream = newFileStream(f1, (void (*)())pclose);
|
||||
}
|
||||
|
||||
static FILE *
|
||||
|
||||
Reference in New Issue
Block a user