dict-process.c revision d198989a7cac917ba0bd341a76d94e8a32267074
/* Copyright (c) 2006-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "array.h"
#include "ioloop.h"
#include "network.h"
#include "fd-close-on-exec.h"
#include "env-util.h"
#include "log.h"
#include "child-process.h"
#include "dict-process.h"
#include <syslog.h>
#include <unistd.h>
#define DICT_SERVER_SOCKET_NAME "dict-server"
struct dict_process {
struct child_process process;
char *path;
int fd;
};
static struct dict_process *dict_process;
{
const char *executable, *const *dicts;
unsigned int i, count;
int log_fd;
if (log_fd < 0)
pid = -1;
else {
if (pid < 0)
i_error("fork() failed: %m");
}
if (pid < 0) {
return -1;
}
if (pid != 0) {
/* master */
return 0;
}
gets ignored. */
i_fatal("dup2(stdin) failed: %m");
i_fatal("dup2(stdout) failed: %m");
/* stderr = log, 3 = listener */
i_fatal("dup2(stderr) failed: %m");
i_fatal("dup2(3) failed: %m");
for (i = 0; i <= 3; i++)
fd_close_on_exec(i, FALSE);
NULL));
}
for (i = 0; i < count; i += 2)
/* make sure we don't leak syslog fd, but do it last so that
any errors above will be logged */
closelog();
return -1;
}
{
}
{
if (errno == EADDRINUSE)
else
return -1;
}
}
{
return;
i_error("close(dict) failed: %m");
}
static void
bool abnormal_exit ATTR_UNUSED)
{
/* not killed by ourself */
}
(void)dict_process_listen(p);
}
void dict_process_init(void)
{
struct dict_process *process;
(void)dict_process_listen(process);
}
void dict_process_deinit(void)
{
}
void dict_process_kill(void)
{
}
}