Lines Matching refs:fd
45 int fd;
46 } control_state = {.fd = -1};
63 int fd;
66 if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
79 close(fd);
84 if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
86 close(fd);
95 close(fd);
100 return (fd);
104 control_listen(int fd)
106 if (control_state.fd != -1)
109 control_state.fd = fd;
110 if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
115 event_set(&control_state.ev, control_state.fd, EV_READ,
162 event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, c->iev.handler,
170 control_connbyfd(int fd)
175 if (c->iev.ibuf.fd == fd)
196 control_close(int fd)
200 if ((c = control_connbyfd(fd)) == NULL) {
201 log_warnx("%s: fd %d: not found", __func__, fd);
209 close(c->iev.ibuf.fd);
221 control_dispatch_imsg(int fd, short event, void *bula)
230 if ((c = control_connbyfd(fd)) == NULL) {
231 log_warnx("%s: fd %d: not found", __func__, fd);
238 control_close(fd);
244 control_close(fd);
249 if (getpeereid(fd, &euid, &egid) == -1) {
250 control_close(fd);
256 control_close(fd);
267 control_close(fd);