… | |
… | |
71 | }; |
71 | }; |
72 | |
72 | |
73 | unix_listener::unix_listener (const char *sockname) |
73 | unix_listener::unix_listener (const char *sockname) |
74 | : accept_ev (this, &unix_listener::accept_cb) |
74 | : accept_ev (this, &unix_listener::accept_cb) |
75 | { |
75 | { |
76 | if ((fd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0) |
76 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
77 | { |
77 | { |
78 | perror ("unable to create listening socket"); |
78 | perror ("unable to create listening socket"); |
79 | exit (EXIT_FAILURE); |
79 | exit (EXIT_FAILURE); |
80 | } |
80 | } |
81 | |
81 | |
… | |
… | |
118 | } |
118 | } |
119 | } |
119 | } |
120 | |
120 | |
121 | int server::getfd (int remote_fd) |
121 | int server::getfd (int remote_fd) |
122 | { |
122 | { |
123 | #if ENABLE_FRILLS && HAVE_UNIX_FDPASS |
|
|
124 | send ("GETFD"); |
123 | send ("GETFD"); |
125 | send (remote_fd); |
124 | send (remote_fd); |
126 | return rxvt_recv_fd (fd); |
125 | return rxvt_recv_fd (fd); |
127 | #else |
|
|
128 | return -1; |
|
|
129 | #endif |
|
|
130 | } |
126 | } |
131 | |
127 | |
132 | void server::log_msg (const char *msg) |
128 | void server::log_msg (const char *msg) |
133 | { |
129 | { |
134 | send ("MSG"), send (msg); |
130 | send ("MSG"), send (msg); |
… | |
… | |
186 | } |
182 | } |
187 | |
183 | |
188 | envv->push_back (0); |
184 | envv->push_back (0); |
189 | |
185 | |
190 | { |
186 | { |
191 | char **old_environ = environ; |
|
|
192 | environ = envv->begin (); |
|
|
193 | |
|
|
194 | rxvt_term *term = new rxvt_term; |
187 | rxvt_term *term = new rxvt_term; |
195 | |
188 | |
196 | term->log_hook = &log_cb; |
189 | term->log_hook = &log_cb; |
197 | term->getfd_hook = &getfd_cb; |
190 | term->getfd_hook = &getfd_cb; |
198 | term->argv = argv; |
191 | term->argv = argv; |
… | |
… | |
209 | success = false; |
202 | success = false; |
210 | } |
203 | } |
211 | |
204 | |
212 | term->log_hook = 0; |
205 | term->log_hook = 0; |
213 | |
206 | |
214 | environ = old_environ; |
|
|
215 | chdir ("/"); |
207 | chdir ("/"); |
216 | |
208 | |
217 | if (!success) |
209 | if (!success) |
218 | term->destroy (); |
210 | term->destroy (); |
219 | |
211 | |
… | |
… | |
230 | int opt_fork, opt_opendisplay, opt_quiet; |
222 | int opt_fork, opt_opendisplay, opt_quiet; |
231 | |
223 | |
232 | int |
224 | int |
233 | main (int argc, const char *const *argv) |
225 | main (int argc, const char *const *argv) |
234 | { |
226 | { |
|
|
227 | rxvt_init (); |
|
|
228 | |
235 | for (int i = 1; i < argc; i++) |
229 | for (int i = 1; i < argc; i++) |
236 | { |
230 | { |
237 | if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) |
231 | if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) |
238 | opt_fork = 1; |
232 | opt_fork = 1; |
239 | else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) |
233 | else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) |
… | |
… | |
245 | rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); |
239 | rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); |
246 | return EXIT_FAILURE; |
240 | return EXIT_FAILURE; |
247 | } |
241 | } |
248 | } |
242 | } |
249 | |
243 | |
250 | rxvt_init (); |
|
|
251 | |
|
|
252 | chdir ("/"); |
244 | chdir ("/"); |
253 | |
245 | |
254 | if (opt_opendisplay) |
246 | if (opt_opendisplay) |
255 | displays.get (getenv ("DISPLAY")); // open display and never release it |
247 | displays.get (getenv ("DISPLAY")); // open display and never release it |
256 | |
248 | |