doveadm-master.c revision c7713320cd35e77543f1bdc7229988a160dae322
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2010-2016 Dovecot authors, see the included COPYING file */
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenstatic bool pid_file_read(const char *path, pid_t *pid_r)
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen unsigned int i;
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen pidfile_path = t_strconcat(doveadm_settings->base_dir,
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen i_fatal("Dovecot is not running (read from %s)", pidfile_path);
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen i_fatal("kill(%s, %d) failed: %m", dec2str(pid), signo);
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen /* wait for a while for the process to die */
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainen for (i = 0; i < 30; i++) {
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenstatic void cmd_stop(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED)
169b1488b6eea7a968021afa4f929b2e26d75d98Timo Sirainenstatic void cmd_reload(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED)
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainenstatic void cmd_service_stop(int argc, char *argv[])
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen path = t_strconcat(doveadm_settings->base_dir, "/master", NULL);
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen i_fatal("net_connect_unix(%s) failed: %m", path);
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen str_append(cmd, "VERSION\tmaster-client\t1\t0\nSTOP");
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen if (write_full(fd, str_data(cmd), str_len(cmd)) < 0)
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen struct istream *input = i_stream_create_fd(fd, IO_BLOCK_SIZE);
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen (line = i_stream_read_next_line(input)) == NULL) {
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen i_error("read(%s) failed: %s", path, i_stream_get_error(input));
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainen i_error("Unexpected input from %s: %s", path, line);
68cc278710182485b6c09e9a9ff8db90a727f343Aki Tuomistruct doveadm_cmd_ver2 doveadm_cmd_reload_ver2 = {
c7713320cd35e77543f1bdc7229988a160dae322Timo Sirainenstruct doveadm_cmd_ver2 doveadm_cmd_service_stop_ver2 = {