aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-11-24 16:02:22 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-11-24 16:02:22 +0000
commit5a539bf5e762a56fe8fae347f7fcee531fbbb399 (patch)
tree9d9157716e943261c150b6e60c08b19219d3548d
parent[w3m-dev 03466] Re: background download when external viewer (diff)
downloadw3m-5a539bf5e762a56fe8fae347f7fcee531fbbb399.tar.gz
w3m-5a539bf5e762a56fe8fae347f7fcee531fbbb399.zip
[w3m-dev 03471] Re: SETPGRP()
* configure: SETPGRP() always defined * proto.h (close_all_fds): added (myExec): #ifdef HAVE_SETPGRP * etc.c (close_all_fds): added (myExec): #ifdef HAVE_SETPGRP (mySystem): #ifndef -> #ifdef * file.c (_doFileCopy): delete #ifdef HAVE_SETPGRP (doFileSave): ditto * image.c (openImgdisplay): delete #ifdef HAVE_SETPGRP use close_all_fds() * search.c (open_migemo): ditto From: Fumitoshi UKAI <ukai@debian.or.jp>
-rw-r--r--ChangeLog17
-rwxr-xr-xconfigure3
-rw-r--r--etc.c46
-rw-r--r--file.c6
-rw-r--r--image.c14
-rw-r--r--proto.h5
-rw-r--r--search.c14
7 files changed, 58 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 05ea7dd..49b478a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-11-25 Fumitoshi UKAI <ukai@debian.or.jp>
+
+ * [w3m-dev 03471] Re: SETPGRP()
+ * configure: SETPGRP() always defined
+ * proto.h (close_all_fds): added
+ (myExec): #ifdef HAVE_SETPGRP
+ * etc.c (close_all_fds): added
+ (myExec): #ifdef HAVE_SETPGRP
+ (mySystem): #ifndef -> #ifdef
+ * file.c (_doFileCopy): delete #ifdef HAVE_SETPGRP
+ (doFileSave): ditto
+ * image.c (openImgdisplay): delete #ifdef HAVE_SETPGRP
+ use close_all_fds()
+ * search.c (open_migemo): ditto
+
2002-11-23 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03466] Re: background download when external viewer
@@ -5054,4 +5069,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.550 2002/11/22 19:24:54 ukai Exp $
+$Id: ChangeLog,v 1.551 2002/11/24 16:02:22 ukai Exp $
diff --git a/configure b/configure
index 40061a8..fd3f788 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: configure,v 1.88 2002/11/21 16:31:35 ukai Exp $
+# $Id: configure,v 1.89 2002/11/24 16:02:22 ukai Exp $
# Configuration.
#
@@ -2008,6 +2008,7 @@ EOF
def_setpgrp='#define SETPGRP() setpgrp( 0, 0 )'
else
def_have_setpgrp=''
+ def_setpgrp='#define SETPGRP() /* no setpgrp() */'
fi
fi
diff --git a/etc.c b/etc.c
index 8f4f39d..0f98636 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.39 2002/11/22 15:57:29 ukai Exp $ */
+/* $Id: etc.c,v 1.40 2002/11/24 16:02:22 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -1294,39 +1294,51 @@ reset_signals(void)
signal(SIGUSR1, SIG_IGN);
}
-void
-myExec(char *command)
-{
- int i;
-
- reset_signals();
- SETPGRP();
- close_tty();
- dup2(open("/dev/null", O_RDONLY), 0);
- dup2(open("/dev/null", O_WRONLY), 1);
- dup2(open("/dev/null", O_WRONLY), 2);
#ifndef FOPEN_MAX
#define FOPEN_MAX 1024 /* XXX */
#endif
+
+void
+close_all_fds(int i)
+{
+ switch (i) { /* fall through */
+ case 0:
+ dup2(open("/dev/null", O_RDONLY), 0);
+ case 1:
+ dup2(open("/dev/null", O_WRONLY), 1);
+ case 2:
+ dup2(open("/dev/null", O_WRONLY), 2);
+ }
/* close all other file descriptors (socket, ...) */
for (i = 3; i < FOPEN_MAX; i++)
close(i);
+}
+
+#ifdef HAVE_SETPGRP
+void
+myExec(char *command)
+{
+ reset_signals();
+ SETPGRP();
+ close_tty();
+ close_all_fds(0);
execl("/bin/sh", "sh", "-c", command, NULL);
exit(127);
}
+#endif
void
mySystem(char *command, int background)
{
if (background) {
-#ifndef HAVE_SETPGRP
- Str cmd = Strnew_charp("start /f ");
- Strcat_charp(cmd, command);
- system(cmd->ptr);
-#else
+#ifdef HAVE_SETPGRP
flush_tty();
if (!fork())
myExec(command);
+#else
+ Str cmd = Strnew_charp("start /f ");
+ Strcat_charp(cmd, command);
+ system(cmd->ptr);
#endif
}
else
diff --git a/file.c b/file.c
index a1080ad..0a4f57b 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.126 2002/11/22 19:24:54 ukai Exp $ */
+/* $Id: file.c,v 1.127 2002/11/24 16:02:22 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -7274,9 +7274,7 @@ _doFileCopy(char *tmpf, char *defstr, int download)
if (!pid) {
reset_signals();
signal(SIGINT, SIG_IGN);
-#ifdef HAVE_SETPGRP
SETPGRP();
-#endif
close_tty();
QuietMessage = TRUE;
fmInitialized = FALSE;
@@ -7374,9 +7372,7 @@ doFileSave(URLFile uf, char *defstr)
if (!pid) {
reset_signals();
signal(SIGINT, SIG_IGN);
-#ifdef HAVE_SETPGRP
SETPGRP();
-#endif
close_tty();
QuietMessage = TRUE;
fmInitialized = FALSE;
diff --git a/image.c b/image.c
index 2c785ba..e2aaeaa 100644
--- a/image.c
+++ b/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.19 2002/11/15 15:57:16 ukai Exp $ */
+/* $Id: image.c,v 1.20 2002/11/24 16:02:22 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
@@ -107,30 +107,22 @@ openImgdisplay()
goto err2;
if (Imgdisplay_pid == 0) {
/* child */
- int i;
reset_signals();
signal(SIGINT, SIG_IGN);
set_environ("W3M_TTY", ttyname_tty());
-#ifdef HAVE_SETPGRP
SETPGRP();
-#endif
close_tty();
close(fdr[0]);
close(fdw[1]);
dup2(fdw[0], 0);
dup2(fdr[1], 1);
- dup2(open("/dev/null", O_WRONLY), 2);
-#ifndef FOPEN_MAX
-#define FOPEN_MAX 1024 /* XXX */
-#endif
- /* close all other file descriptors (socket, ...) */
- for (i = 3; i < FOPEN_MAX; i++)
- close(i);
+ close_all_fds(2);
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);
}
close(fdr[1]);
diff --git a/proto.h b/proto.h
index 5954883..8403329 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.60 2002/11/22 15:49:44 ukai Exp $ */
+/* $Id: proto.h,v 1.61 2002/11/24 16:02:22 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -560,7 +560,10 @@ extern char *last_modified(Buffer *buf);
extern Str romanNumeral(int n);
extern Str romanAlphabet(int n);
extern void reset_signals(void);
+extern void close_all_fds(int i);
+#ifdef HAVE_SETPGRP
extern void myExec(char *command);
+#endif
extern void mySystem(char *command, int background);
extern Str myExtCommand(char *cmd, char *arg, int redirect);
extern Str myEditor(char *cmd, char *file, int line);
diff --git a/search.c b/search.c
index 9b3d424..25c1cab 100644
--- a/search.c
+++ b/search.c
@@ -1,4 +1,4 @@
-/* $Id: search.c,v 1.21 2002/11/06 15:05:35 ukai Exp $ */
+/* $Id: search.c,v 1.22 2002/11/24 16:02:22 ukai Exp $ */
#include "fm.h"
#include "regex.h"
#include <signal.h>
@@ -50,24 +50,16 @@ open_migemo(char *migemo_command)
goto err2;
if (migemo_pid == 0) {
/* child */
- int i;
reset_signals();
-#ifdef HAVE_SETPGRP
SETPGRP();
-#endif
close_tty();
close(fdr[0]);
close(fdw[1]);
dup2(fdw[0], 0);
dup2(fdr[1], 1);
- dup2(open("/dev/null", O_WRONLY), 2);
-#ifndef FOPEN_MAX
-#define FOPEN_MAX 1024 /* XXX */
-#endif
- /* close all other file descriptors (socket, ...) */
- for (i = 3; i < FOPEN_MAX; i++)
- close(i);
+ close_all_fds(2);
execl("/bin/sh", "sh", "-c", migemo_command, NULL);
+ /* XXX: ifndef HAVE_SETPGRP, use "start /f"? */
exit(1);
}
close(fdr[1]);