[w3m-dev 03646] setup child process, local CGI

* etc.c (reset_signals): static
			don't ignore SIGUSR1
	(close_all_fds_except): static
			DEV_NULL_PATH
	(setup_child): added
	(myExec): rewrite
	(mySystem): rewrite
* file.c (readHeader): check image_source
	(loadGeneralFile): check image_source
	(doExternal): use setup_child
	(_doFileCopy): use setup_child
	(doFileSave): use setup_child
	(uncompress_stream): check image_source
			use setup_child
* image.c (getCharSize): no need stderr redirect
	(openImgdisplay): use setup_child
	(loadImage): use setup_child
	(getImageSize): no need stderr redirect
* local.c (writeLocalCookie): check Local_cookie_file
	(localcgi_popen_rw): added
	(localcgi_popen_r): deleted
	(localcgi_post): rewrite
	(localcgi_get): deleted
* proto.h (localcgi_get): defined by localcgi_post
	(reset_signals): deleted
	(close_all_fds_except): deleted
	(close_all_fds): deleted
	(setup_child): added
* search.c (open_migemo): use setup_child, myExec
* w3mimgdisplay.c (main): use DEV_NULL_PATH
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-01-17 16:57:17 +00:00
parent 4e7b05a901
commit 439d2745a5
8 changed files with 153 additions and 188 deletions

27
image.c
View File

@@ -1,4 +1,4 @@
/* $Id: image.c,v 1.25 2003/01/15 16:11:43 ukai Exp $ */
/* $Id: image.c,v 1.26 2003/01/17 16:57:19 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
@@ -54,7 +54,7 @@ getCharSize()
tmp = Strnew();
if (!strchr(Imgdisplay, '/'))
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
Strcat_m_charp(tmp, Imgdisplay, " -test 2> /dev/null", NULL);
Strcat_m_charp(tmp, Imgdisplay, " -test", NULL);
f = popen(tmp->ptr, "r");
if (!f)
return FALSE;
@@ -103,23 +103,18 @@ openImgdisplay()
goto err2;
if (Imgdisplay_pid == 0) {
/* child */
reset_signals();
signal(SIGINT, SIG_IGN);
set_environ("W3M_TTY", ttyname_tty());
SETPGRP();
close_tty();
close(fdr[0]);
close(fdw[1]);
dup2(fdw[0], 0);
dup2(fdr[1], 1);
close_all_fds(2);
setup_child(FALSE, 2, -1);
set_environ("W3M_TTY", ttyname_tty());
if (!strchr(Imgdisplay, '/'))
cmd = Strnew_m_charp(w3m_auxbin_dir(), "/", Imgdisplay, NULL)->ptr;
else
cmd = Imgdisplay;
execl("/bin/sh", "sh", "-c", cmd, NULL);
/* XXX: ifndef HAVE_SETPGRP, use start /f ? */
exit(1);
myExec(cmd);
/* XXX: ifdef __EMX__, use start /f ? */
}
close(fdr[1]);
close(fdw[0]);
@@ -453,12 +448,7 @@ loadImage(int flag)
flush_tty();
if ((cache->pid = fork()) == 0) {
Buffer *b;
reset_signals();
signal(SIGINT, SIG_IGN);
close_tty();
close_all_fds(2);
QuietMessage = TRUE;
fmInitialized = FALSE;
setup_child(TRUE, 0, -1);
image_source = cache->file;
b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL);
if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6))
@@ -554,8 +544,7 @@ getImageSize(ImageCache * cache)
tmp = Strnew();
if (!strchr(Imgdisplay, '/'))
Strcat_m_charp(tmp, w3m_auxbin_dir(), "/", NULL);
Strcat_m_charp(tmp, Imgdisplay, " -size ", shell_quote(cache->file),
" 2> /dev/null", NULL);
Strcat_m_charp(tmp, Imgdisplay, " -size ", shell_quote(cache->file), NULL);
f = popen(tmp->ptr, "r");
if (!f)
return FALSE;