diff --git a/honoka/plugins/primeprediction.cpp b/honoka/plugins/primeprediction.cpp index b5a9ef6..256a0da 100644 --- a/honoka/plugins/primeprediction.cpp +++ b/honoka/plugins/primeprediction.cpp @@ -84,6 +84,7 @@ PrimePrediction::PrimePrediction(ConfigPointer cfg) : Predictor(cfg) { m_iconv.set_encoding ("EUC-JP"); + prime_pid = -1; mid = shmget(IPC_PRIVATE,sizeof(bool),IPC_CREAT | 0666); if (mid != -1) { con = (bool *)shmat(mid,0,0); @@ -109,6 +110,10 @@ PrimePrediction::~PrimePrediction() { disconnect(); + if (prime_pid != -1) { + kill(prime_pid,SIGKILL); + wait(NULL); + } if (mid != -1) shmctl(mid,IPC_RMID,0); } @@ -193,6 +198,7 @@ close(ifd); close(ofd); con[0] = false; + prime_pid = -1; } @@ -206,7 +212,8 @@ if (con[0]) return true; if (pipe(in_fd) == -1) return false; if (pipe(out_fd) == -1) return false; - switch(fork()) { + prime_pid = fork(); + switch(prime_pid) { case -1: { close(in_fd[0]); close(in_fd[1]); diff --git a/honoka/plugins/primeprediction.h b/honoka/plugins/primeprediction.h index b61f508..9464fe6 100644 --- a/honoka/plugins/primeprediction.h +++ b/honoka/plugins/primeprediction.h @@ -70,6 +70,7 @@ bool *con; IConvert m_iconv; int mid; + pid_t prime_pid; protected: ResultEntry parser(const String &str); };