… | |
… | |
51 | : read_ev (this, &server::read_cb), |
51 | : read_ev (this, &server::read_cb), |
52 | log_cb (this, &server::log_msg), |
52 | log_cb (this, &server::log_msg), |
53 | getfd_cb (this, &server::getfd) |
53 | getfd_cb (this, &server::getfd) |
54 | { |
54 | { |
55 | this->fd = fd; |
55 | this->fd = fd; |
|
|
56 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
57 | fcntl (fd, F_SETFL, 0); |
56 | read_ev.start (fd, ev::READ); |
58 | read_ev.start (fd, ev::READ); |
57 | } |
59 | } |
58 | |
60 | |
59 | void err (const char *format = 0, ...); |
61 | void err (const char *format = 0, ...); |
60 | }; |
62 | }; |
… | |
… | |
83 | perror ("unable to create listening socket"); |
85 | perror ("unable to create listening socket"); |
84 | exit (EXIT_FAILURE); |
86 | exit (EXIT_FAILURE); |
85 | } |
87 | } |
86 | |
88 | |
87 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
89 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
90 | fcntl (fd, F_SETFL, O_NONBLOCK); |
88 | |
91 | |
89 | sa.sun_family = AF_UNIX; |
92 | sa.sun_family = AF_UNIX; |
90 | strcpy (sa.sun_path, sockname); |
93 | strcpy (sa.sun_path, sockname); |
91 | |
94 | |
92 | unlink (rxvt_connection::unix_sockname ()); |
95 | unlink (rxvt_connection::unix_sockname ()); |
… | |
… | |
113 | void unix_listener::accept_cb (ev::io &w, int revents) |
116 | void unix_listener::accept_cb (ev::io &w, int revents) |
114 | { |
117 | { |
115 | int fd2 = accept (fd, 0, 0); |
118 | int fd2 = accept (fd, 0, 0); |
116 | |
119 | |
117 | if (fd2 >= 0) |
120 | if (fd2 >= 0) |
118 | { |
|
|
119 | fcntl (fd2, F_SETFD, FD_CLOEXEC); |
|
|
120 | new server (fd2); |
121 | new server (fd2); |
121 | } |
|
|
122 | } |
122 | } |
123 | |
123 | |
124 | int server::getfd (int remote_fd) |
124 | int server::getfd (int remote_fd) |
125 | { |
125 | { |
126 | send ("GETFD"); |
126 | send ("GETFD"); |