equal
deleted
inserted
replaced
45 static void sig_handler(int, short, void *); |
45 static void sig_handler(int, short, void *); |
46 static enum m_type m_type(const char *); |
46 static enum m_type m_type(const char *); |
47 static void usage(void); |
47 static void usage(void); |
48 |
48 |
49 static struct imsgev iev_pop3e; |
49 static struct imsgev iev_pop3e; |
50 static pid_t pop3e_pid; |
|
51 static const char *mpath; |
50 static const char *mpath; |
52 static int mtype = M_MBOX; |
51 static int mtype = M_MBOX; |
53 |
52 |
54 int |
53 int |
55 main(int argc, char *argv[]) |
54 main(int argc, char *argv[]) |
100 set_nonblocking(pair[0]); |
99 set_nonblocking(pair[0]); |
101 set_nonblocking(pair[1]); |
100 set_nonblocking(pair[1]); |
102 if ((pw = getpwnam(POP3D_USER)) == NULL) |
101 if ((pw = getpwnam(POP3D_USER)) == NULL) |
103 fatalx("main: getpwnam " POP3D_USER); |
102 fatalx("main: getpwnam " POP3D_USER); |
104 |
103 |
105 pop3e_pid = pop3_main(pair, pw); |
104 pop3_main(pair, pw); |
106 close(pair[1]); |
105 close(pair[1]); |
107 setproctitle("[priv]"); |
106 setproctitle("[priv]"); |
108 logit(LOG_INFO, "pop3d ready; type:%s, path:%s", mtype_str, mpath); |
107 logit(LOG_INFO, "pop3d ready; type:%s, path:%s", mtype_str, mpath); |
109 event_init(); |
108 event_init(); |
110 signal_set(&ev_sigint, SIGINT, sig_handler, NULL); |
109 signal_set(&ev_sigint, SIGINT, sig_handler, NULL); |
204 imsgev_clear(&iev_pop3e); |
203 imsgev_clear(&iev_pop3e); |
205 imsgev_close(&iev_pop3e); |
204 imsgev_close(&iev_pop3e); |
206 event_loopexit(NULL); |
205 event_loopexit(NULL); |
207 break; |
206 break; |
208 case SIGCHLD: |
207 case SIGCHLD: |
209 if (waitpid(pop3e_pid, &status, WNOHANG) > 0) |
208 if (waitpid(WAIT_ANY, &status, WNOHANG) > 0) |
210 if (WIFEXITED(status) || WIFSIGNALED(status)) { |
209 if ((WIFEXITED(status) && WEXITSTATUS(status) != 0) || |
|
210 WIFSIGNALED(status)) { |
211 logit(LOG_ERR, "Lost pop3 engine"); |
211 logit(LOG_ERR, "Lost pop3 engine"); |
212 event_loopexit(NULL); |
212 event_loopexit(NULL); |
213 } |
213 } |
214 break; |
214 break; |
215 } |
215 } |