[w3m-dev 02870] don't kill migemo by SIGINT

* main.c (w3m_exit): init_migemo() to kill migemo
* search.c: #include <unistd.h>
* search.c (migemo_active): added
* search.c (migemo_pid): added
* search.c (init_migemo): migemo_active = use_migemo
* search.c (init_migemo): kill migemo_pid
* search.c (open_migemo): s/pid/migemo_pid/
* search.c (open_migemo): setpgrp()
* search.c (open_migemo): s/use_migemo/migemo_active/
* search.c (migemostr): ditto
* search.c (forwardSearch): ditto
* search.c (backwardSearch): ditto
From: Fumitoshi UKAI  <ukai@debian.or.jp>
This commit is contained in:
Fumitoshi UKAI
2002-01-17 15:05:43 +00:00
parent 48c6df47d0
commit 7fe83699ea
3 changed files with 40 additions and 11 deletions
+17 -1
View File
@@ -1,3 +1,19 @@
2002-01-18 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02870] don't kill migemo by SIGINT
* main.c (w3m_exit): init_migemo() to kill migemo
* search.c: #include <unistd.h>
* search.c (migemo_active): added
* search.c (migemo_pid): added
* search.c (init_migemo): migemo_active = use_migemo
* search.c (init_migemo): kill migemo_pid
* search.c (open_migemo): s/pid/migemo_pid/
* search.c (open_migemo): setpgrp()
* search.c (open_migemo): s/use_migemo/migemo_active/
* search.c (migemostr): ditto
* search.c (forwardSearch): ditto
* search.c (backwardSearch): ditto
2002-01-17 Fumitoshi UKAI <ukai@debian.or.jp> 2002-01-17 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02867] mark URL for external URIs * [w3m-dev 02867] mark URL for external URIs
@@ -2105,4 +2121,4 @@
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.239 2002/01/17 11:06:45 ukai Exp $ $Id: ChangeLog,v 1.240 2002/01/17 15:05:43 ukai Exp $
+4 -1
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.65 2002/01/17 11:06:45 ukai Exp $ */ /* $Id: main.c,v 1.66 2002/01/17 15:05:43 ukai Exp $ */
#define MAINPROGRAM #define MAINPROGRAM
#include "fm.h" #include "fm.h"
#include <signal.h> #include <signal.h>
@@ -4779,6 +4779,9 @@ deleteFiles()
void void
w3m_exit(int i) w3m_exit(int i)
{ {
#ifdef USE_MIGEMO
init_migemo(); /* close pipe to migemo */
#endif
deleteFiles(); deleteFiles();
#ifdef USE_SSL #ifdef USE_SSL
free_ssl_ctx(); free_ssl_ctx();
+19 -9
View File
@@ -1,8 +1,9 @@
/* $Id: search.c,v 1.14 2002/01/17 10:29:14 ukai Exp $ */ /* $Id: search.c,v 1.15 2002/01/17 15:05:43 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include "regex.h" #include "regex.h"
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
static void static void
set_mark(Line *l, int pos, int epos) set_mark(Line *l, int pos, int epos)
@@ -14,15 +15,21 @@ set_mark(Line *l, int pos, int epos)
#ifdef USE_MIGEMO #ifdef USE_MIGEMO
/* Migemo: romaji --> kana+kanji in regexp */ /* Migemo: romaji --> kana+kanji in regexp */
static FILE *migemor, *migemow; static FILE *migemor, *migemow;
static int migemo_active;
static int migemo_pid;
void void
init_migemo() init_migemo()
{ {
migemo_active = use_migemo;
if (migemor != NULL) if (migemor != NULL)
fclose(migemor); fclose(migemor);
if (migemow != NULL) if (migemow != NULL)
fclose(migemow); fclose(migemow);
migemor = migemow = NULL; migemor = migemow = NULL;
if (migemo_pid)
kill(migemo_pid, SIGTERM);
migemo_pid = 0;
} }
static int static int
@@ -30,7 +37,7 @@ open_migemo(char *migemo_command)
{ {
int fdr[2]; int fdr[2];
int fdw[2]; int fdw[2];
int pid;
if (pipe(fdr) < 0) if (pipe(fdr) < 0)
goto err0; goto err0;
if (pipe(fdw) < 0) if (pipe(fdw) < 0)
@@ -38,12 +45,15 @@ open_migemo(char *migemo_command)
flush_tty(); flush_tty();
/* migemow:fdw[1] -|-> fdw[0]=0 {migemo} fdr[1]=1 -|-> fdr[0]:migemor */ /* migemow:fdw[1] -|-> fdw[0]=0 {migemo} fdr[1]=1 -|-> fdr[0]:migemor */
pid = fork(); migemo_pid = fork();
if (pid < 0) if (migemo_pid < 0)
goto err2; goto err2;
if (pid == 0) { if (migemo_pid == 0) {
/* child */ /* child */
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
#ifdef HAVE_SETPGRP
setpgrp();
#endif
close_tty(); close_tty();
close(fdr[0]); close(fdr[0]);
close(fdw[1]); close(fdw[1]);
@@ -65,7 +75,7 @@ open_migemo(char *migemo_command)
close(fdr[0]); close(fdr[0]);
close(fdr[1]); close(fdr[1]);
err0: err0:
use_migemo = 0; migemo_active = 0;
return 0; return 0;
} }
@@ -94,7 +104,7 @@ migemostr(char *str)
err: err:
/* XXX: backend migemo is not working? */ /* XXX: backend migemo is not working? */
init_migemo(); init_migemo();
use_migemo = 0; migemo_active = 0;
return str; return str;
} }
#endif /* USE_MIGEMO */ #endif /* USE_MIGEMO */
@@ -108,7 +118,7 @@ forwardSearch(Buffer *buf, char *str)
int pos; int pos;
#ifdef USE_MIGEMO #ifdef USE_MIGEMO
if (use_migemo) { if (migemo_active) {
if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL) if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL)
&& ((p = regexCompile(str, IgnoreCase)) != NULL)) { && ((p = regexCompile(str, IgnoreCase)) != NULL)) {
message(p, 0, 0); message(p, 0, 0);
@@ -186,7 +196,7 @@ backwardSearch(Buffer *buf, char *str)
int pos; int pos;
#ifdef USE_MIGEMO #ifdef USE_MIGEMO
if (use_migemo) { if (migemo_active) {
if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL) if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL)
&& ((p = regexCompile(str, IgnoreCase)) != NULL)) { && ((p = regexCompile(str, IgnoreCase)) != NULL)) {
message(p, 0, 0); message(p, 0, 0);