summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-11 01:06:56 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-11 01:06:56 +0000
commit3736c5f3635863e54ab2cc47860628d26855c749 (patch)
tree3c1dadec1b75557463fcc740429cceb6e948f998 /external
parent63bf2a90a6d6fb0859e4c9dd9fcac85de9adc0f1 (diff)
downloadlibrcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.gz
librcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.bz2
librcc-3736c5f3635863e54ab2cc47860628d26855c749.tar.xz
librcc-3736c5f3635863e54ab2cc47860628d26855c749.zip
Transliteration and Documentation Update
- Fix: Autodetection of dissabled charsets. - Fix: Cleanely terminate external process if parrent thread terminated. - Transliteration for Russian, Ukrainian and using IConv. - Documentation Update.
Diffstat (limited to 'external')
-rw-r--r--external/rccexternal.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/external/rccexternal.c b/external/rccexternal.c
index 47f628a..292ee5d 100644
--- a/external/rccexternal.c
+++ b/external/rccexternal.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "../config.h"
@@ -24,19 +25,37 @@
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif /* HAVE_SYS_UN_H */
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif /* JAVE_SYS_TIME_H */
+
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
+#endif /* HAVE_SIGNAL_H */
#include <glib/gthread.h>
#include "../src/rccexternal.h"
#include "rcclibtranslate.h"
+#define RCC_EXIT_CHECK_TIMEOUT 10 /* seconds */
+
int main() {
+#ifdef HAVE_SIGNAL_H
+ struct sigaction act;
+#endif /* HAVE_PWD_H */
+ int err;
+ struct timeval tv;
+ fd_set fdcon;
+
int s, sd;
char addr[376];
const char *rcc_home_dir;
struct sockaddr_un mysock, clisock;
socklen_t socksize;
+
+ pid_t parentpid;
pid_t mypid;
unsigned char loopflag = 1;
@@ -49,6 +68,8 @@ int main() {
struct passwd *pw;
#endif /* HAVE_PWD_H */
+
+ parentpid = getppid();
mypid = getpid();
rcc_home_dir = getenv ("HOME");
@@ -78,13 +99,34 @@ int main() {
mysock.sun_path[sizeof(mysock.sun_path)-1]=0;
unlink(addr);
+
if (bind(s,(struct sockaddr*)&mysock,sizeof(mysock))==-1) return -1;
if (listen(s,1)<0) {
unlink(addr);
return -1;
}
+#ifdef HAVE_SIGNAL_H
+ act.sa_handler = SIG_IGN;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGPIPE,&act,NULL);
+ sigaction(SIGINT,&act,NULL);
+#endif /* HAVE_SIGNAL_H */
+
while (loopflag) {
+ tv.tv_sec = RCC_EXIT_CHECK_TIMEOUT;
+ tv.tv_usec = 0;
+
+ FD_ZERO(&fdcon);
+ FD_SET(s, &fdcon);
+
+ err = select(s+1, &fdcon, NULL, NULL, &tv);
+ if (err<=0) {
+ if (getppid() != parentpid) break;
+ continue;
+ }
+
sd = accept(s,(struct sockaddr*)&clisock,&socksize);
if (sd < 0) continue;