… | |
… | |
191 | catch (const class rxvt_failure_exception &e) |
191 | catch (const class rxvt_failure_exception &e) |
192 | { |
192 | { |
193 | success = false; |
193 | success = false; |
194 | } |
194 | } |
195 | |
195 | |
|
|
196 | term->log_hook = 0; |
|
|
197 | |
196 | environ = old_environ; |
198 | environ = old_environ; |
|
|
199 | chdir ("/"); |
197 | |
200 | |
198 | if (!success) |
201 | if (!success) |
199 | term->destroy (); |
202 | term->destroy (); |
200 | |
203 | |
201 | send ("END"); send (success ? 1 : 0); |
204 | send ("END"); send (success ? 1 : 0); |
… | |
… | |
206 | } |
209 | } |
207 | else |
210 | else |
208 | return err (); |
211 | return err (); |
209 | } |
212 | } |
210 | |
213 | |
|
|
214 | int opt_fork, opt_opendisplay, opt_quiet; |
|
|
215 | |
211 | int |
216 | int |
212 | main (int argc, const char *const *argv) |
217 | main (int argc, const char *const *argv) |
213 | { |
218 | { |
|
|
219 | for (int i = 1; i < argc; i++) |
|
|
220 | { |
|
|
221 | if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) |
|
|
222 | opt_fork = 1; |
|
|
223 | else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) |
|
|
224 | opt_opendisplay = 1; |
|
|
225 | else if (!strcmp (argv [i], "-q") || !strcmp (argv [i], "--quiet")) |
|
|
226 | opt_quiet = 1; |
|
|
227 | else |
|
|
228 | { |
|
|
229 | rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); |
|
|
230 | return EXIT_FAILURE; |
|
|
231 | } |
|
|
232 | } |
|
|
233 | |
214 | rxvt_init_signals (); |
234 | rxvt_init (); |
|
|
235 | |
|
|
236 | chdir ("/"); |
|
|
237 | |
|
|
238 | if (opt_opendisplay) |
|
|
239 | displays.get (getenv ("DISPLAY")); // open display and never release it |
215 | |
240 | |
216 | char *sockname = rxvt_connection::unix_sockname (); |
241 | char *sockname = rxvt_connection::unix_sockname (); |
217 | unix_listener l (sockname); |
242 | unix_listener l (sockname); |
|
|
243 | |
|
|
244 | if (!opt_quiet) |
|
|
245 | { |
218 | printf ("rxvtd listening on %s.\n", sockname); |
246 | printf ("rxvt-unicode daemon listening on %s.\n", sockname); |
|
|
247 | fflush (stdout); |
|
|
248 | } |
|
|
249 | |
219 | free (sockname); |
250 | free (sockname); |
220 | |
251 | |
221 | iom.loop (); |
252 | if (opt_fork) |
|
|
253 | { |
|
|
254 | pid_t pid = fork (); |
222 | |
255 | |
223 | #if 0 |
256 | if (pid < 0) |
224 | if (rxvt_init (argc, argv) == NULL) |
257 | { |
|
|
258 | rxvt_log ("unable to fork daemon, aborting.\n"); |
225 | return EXIT_FAILURE; |
259 | return EXIT_FAILURE; |
|
|
260 | } |
|
|
261 | else if (pid > 0) |
|
|
262 | _exit (EXIT_SUCCESS); |
|
|
263 | } |
226 | |
264 | |
227 | dR; |
265 | io_manager::loop (); |
228 | rxvt_main_loop (aR); /* main processing loop */ |
266 | |
229 | #endif |
|
|
230 | return EXIT_SUCCESS; |
267 | return EXIT_SUCCESS; |
231 | } |
268 | } |
232 | |
269 | |