diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-24 16:02:22 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-11-24 16:02:22 +0000 |
commit | 5a539bf5e762a56fe8fae347f7fcee531fbbb399 (patch) | |
tree | 9d9157716e943261c150b6e60c08b19219d3548d | |
parent | [w3m-dev 03466] Re: background download when external viewer (diff) | |
download | w3m-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>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 17 | ||||
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | etc.c | 46 | ||||
-rw-r--r-- | file.c | 6 | ||||
-rw-r--r-- | image.c | 14 | ||||
-rw-r--r-- | proto.h | 5 | ||||
-rw-r--r-- | search.c | 14 |
7 files changed, 58 insertions, 47 deletions
@@ -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 $ @@ -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 @@ -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 @@ -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; @@ -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]); @@ -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); @@ -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]); |