--- rxvt-unicode/src/rxvtd.C 2007/11/11 04:08:00 1.34 +++ rxvt-unicode/src/rxvtd.C 2007/12/13 18:24:36 1.42 @@ -48,11 +48,14 @@ int getfd (int remote_fd); server (int fd) - : read_ev (this, &server::read_cb), - log_cb (this, &server::log_msg), - getfd_cb (this, &server::getfd) { + read_ev.set (this); + log_cb.set (this); + getfd_cb.set (this); + this->fd = fd; + fcntl (fd, F_SETFD, FD_CLOEXEC); + fcntl (fd, F_SETFL, 0); read_ev.start (fd, ev::READ); } @@ -68,8 +71,9 @@ }; unix_listener::unix_listener (const char *sockname) -: accept_ev (this, &unix_listener::accept_cb) { + accept_ev.set (this); + sockaddr_un sa; if (strlen (sockname) >= sizeof(sa.sun_path)) @@ -85,6 +89,7 @@ } fcntl (fd, F_SETFD, FD_CLOEXEC); + fcntl (fd, F_SETFL, O_NONBLOCK); sa.sun_family = AF_UNIX; strcpy (sa.sun_path, sockname); @@ -115,10 +120,7 @@ int fd2 = accept (fd, 0, 0); if (fd2 >= 0) - { - fcntl (fd2, F_SETFD, FD_CLOEXEC); - new server (fd2); - } + new server (fd2); } int server::getfd (int remote_fd) @@ -196,11 +198,11 @@ term->log_hook = &log_cb; term->getfd_hook = &getfd_cb; - bool success; + bool success = true; try { - success = term->init (argv, envv); + term->init (argv, envv); } catch (const class rxvt_failure_exception &e) { @@ -273,9 +275,11 @@ } else if (pid > 0) _exit (EXIT_SUCCESS); + + ev_default_fork (); } - ev::ev_loop (0); + ev_loop (0); return EXIT_SUCCESS; }