-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 58e42d149ad235ecfa66eae5c350f8c60e0c04f4: path_to: revision_to:
commit 58e42d149ad235ecfa66eae5c350f8c60e0c04f4 Author: Marc Lehmann <schmorp@schmorp.de> Date: Thu Nov 27 10:12:10 2003 +0000 *** empty log message *** diff --git a/src/Makefile.in b/src/Makefile.in
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.4 2003/11/26 10:42:34 pcg Exp $ +# $Id: Makefile.in,v 1.5 2003/11/27 10:12:10 pcg Exp $ @MCOMMON@ LINT = lint -DNARROWPROTO=1 $(XINC) -chapbxz @@ -52,6 +52,10 @@ INSTALL_LIBRXVT = @INSTALL_LIBRXVT@ RXVT_BASENAME=`$(ECHO) $(RXVTNAME)|$(SED) 's/$(EXEEXT)$$//'|$(SED) '$(transform)'` RXVT_BINNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)$(EXEEXT) RXVT_VERNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)-$(VERSION)$(EXEEXT) +RXVTC_BINNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)c$(EXEEXT) +RXVTC_VERNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)c-$(VERSION)$(EXEEXT) +RXVTD_BINNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)d$(EXEEXT) +RXVTD_VERNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)d-$(VERSION)$(EXEEXT) RXVT_OLDNAME=$(DESTDIR)$(bindir)/$(RXVT_BASENAME)-old$(EXEEXT) EXTPROS = command.extpro defaultfont.extpro graphics.extpro grkelot.extpro \ @@ -148,16 +152,15 @@ install: allbin alldoc $(ECHO) "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) librxvt.la $(DESTDIR)$(libdir)/librxvt.la"; \ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) librxvt.la $(DESTDIR)$(libdir)/librxvt.la; \ fi - @if test -f $(RXVT_BINNAME); then \ - $(ECHO) "$(RMF) $(RXVT_OLDNAME)"; \ - $(RMF) $(RXVT_OLDNAME); \ - $(ECHO) "$(MV) $(RXVT_BINNAME) $(RXVT_OLDNAME)"; \ - $(MV) $(RXVT_BINNAME) $(RXVT_OLDNAME); \ - fi - @$(ECHO) "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) rxvt $(RXVT_VERNAME)" - @$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) rxvt $(RXVT_VERNAME) - @$(ECHO) "$(LN) $(RXVT_VERNAME) $(RXVT_BINNAME)" - @$(LN) $(RXVT_VERNAME) $(RXVT_BINNAME) + $(RMF) $(RXVT_BINNAME) + $(RMF) $(RXVTC_BINNAME) + $(RMF) $(RXVTD_BINNAME) + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) rxvt $(RXVT_VERNAME) + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) rxvtc $(RXVTC_VERNAME) + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) rxvtd $(RXVTD_VERNAME) + $(LN) $(RXVT_VERNAME) $(RXVT_BINNAME) + $(LN) $(RXVTC_VERNAME) $(RXVTC_BINNAME) + $(LN) $(RXVTD_VERNAME) $(RXVTD_BINNAME) uninstall: @$(ECHO) $(RMF) $(RXVT_VERNAME) diff --git a/src/command.C b/src/command.C
--- a/src/command.C +++ b/src/command.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: command.c *----------------------------------------------------------------------* - * $Id: command.C,v 1.8 2003/11/26 10:42:34 pcg Exp $ + * $Id: command.C,v 1.9 2003/11/27 10:12:10 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> @@ -706,6 +706,8 @@ rxvt_term::process_x_events () void rxvt_term::blink_cb (time_watcher &w) { + SET_R (this); + w.at += BLINK_INTERVAL; hidden_cursor = !hidden_cursor; want_refresh = 1; @@ -715,6 +717,8 @@ rxvt_term::blink_cb (time_watcher &w) void rxvt_term::x_cb (io_watcher &w, short revents) { + SET_R (this); + process_x_events (); flush (); @@ -794,13 +798,14 @@ rxvt_term::pty_fill () else if (n < 0 && errno == EAGAIN) return false; - rxvt_clean_exit (); - exit (EXIT_FAILURE); /* bad order of events? */ + destroy (); } void rxvt_term::pty_cb (io_watcher &w, short revents) { + SET_R (this); + // loop, but don't allow a single term to monopolize us // the number of loops is fully arbitrary, and thus wrong for (int i = 7; i-- && pty_fill (); ) @@ -1045,6 +1050,8 @@ rxvt_term::pointer_blank () void rxvt_term::pointer_cb (time_watcher &w) { + SET_R (this); + pointer_blank (); } #endif @@ -1251,10 +1258,10 @@ rxvt_process_x_event(pR_ XEvent *ev) case ClientMessage: if (ev->xclient.format == 32 && (Atom)ev->xclient.data.l[0] == R->xa[XA_WMDELETEWINDOW]) - exit(EXIT_SUCCESS); + R->destroy (); #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) protocol */ - if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] + else if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] && (ev->xclient.data.l[0] == DndFile || ev->xclient.data.l[0] == DndDir || ev->xclient.data.l[0] == DndLink)) { diff --git a/src/init.C b/src/init.C
--- a/src/init.C +++ b/src/init.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: init.c *----------------------------------------------------------------------* - * $Id: init.C,v 1.7 2003/11/26 10:42:34 pcg Exp $ + * $Id: init.C,v 1.8 2003/11/27 10:12:10 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> @@ -1303,27 +1303,8 @@ rxvt_run_command(pR_ const char *const *argv) else #endif er = -1; - rxvt_get_ttymode(&(R->tio), er); - -/* install exit handler for cleanup */ -#ifdef HAVE_ATEXIT - atexit(rxvt_clean_exit); -#else -# ifdef HAVE_ON_EXIT - on_exit(rxvt_clean_exit, NULL); /* non-ANSI exit handler */ -# endif -#endif - - signal(SIGHUP, rxvt_Exit_signal); -#ifndef __svr4__ - signal(SIGINT, rxvt_Exit_signal); -#endif - signal(SIGQUIT, rxvt_Exit_signal); - signal(SIGTERM, rxvt_Exit_signal); - signal(SIGCHLD, rxvt_Child_signal); -/* need to trap SIGURG for SVR4 (Unixware) rlogin */ -/* signal (SIGURG, SIG_DFL); */ + rxvt_get_ttymode(&(R->tio), er); #ifndef __QNX__ /* spin off the command interpreter */ @@ -1417,17 +1398,17 @@ rxvt_run_child(pR_ const char *const *argv) } /* reset signals and spin off the command interpreter */ - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - signal(SIGCHLD, SIG_DFL); + signal (SIGINT, SIG_DFL); + signal (SIGQUIT, SIG_DFL); + signal (SIGCHLD, SIG_DFL); /* * mimick login's behavior by disabling the job control signals * a shell that wants them can turn them back on */ #ifdef SIGTSTP - signal(SIGTSTP, SIG_IGN); - signal(SIGTTIN, SIG_IGN); - signal(SIGTTOU, SIG_IGN); + signal (SIGTSTP, SIG_IGN); + signal (SIGTTIN, SIG_IGN); + signal (SIGTTOU, SIG_IGN); #endif /* SIGTSTP */ /* set window size */ diff --git a/src/main.C b/src/main.C
--- a/src/main.C +++ b/src/main.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.7 2003/11/26 10:42:34 pcg Exp $ + * $Id: main.C,v 1.8 2003/11/27 10:12:10 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> @@ -67,16 +67,62 @@ rxvt_term::rxvt_term () #ifdef POINTER_BLANK pointer_ev (this, &rxvt_term::pointer_cb), #endif - x_ev (this, &rxvt_term::x_cb) + x_ev (this, &rxvt_term::x_cb), + destroy_ev (this, &rxvt_term::destroy_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } rxvt_term::~rxvt_term () { + rxvt_scr_release (this); + +#ifndef NO_SETOWNER_TTYDEV + rxvt_privileged_ttydev (this, RESTORE); +#endif +#ifdef UTMP_SUPPORT + rxvt_privileged_utmp (this, RESTORE); +#endif +#ifdef USE_XIM + if (Input_Context != NULL) + { + XDestroyIC (Input_Context); + Input_Context = NULL; + } +#endif + + if (cmd_fd >= 0) + close (cmd_fd); + + if (Xfd >= 0) + XCloseDisplay (Xdisplay); + delete PixColors; } +void +rxvt_term::destroy () +{ + pty_ev.stop (); + x_ev.stop (); +#ifdef CURSOR_BLINK + blink_ev.stop (); +#endif +#ifdef POINTER_BLANK + pointer_ev.stop (); +#endif + + destroy_ev.start (0); +} + +void +rxvt_term::destroy_cb (time_watcher &w) +{ + SET_R (this); + + delete this; +} + /*----------------------------------------------------------------------*/ /* rxvt_init() */ /* LIBPROTO */ @@ -95,6 +141,38 @@ rxvt_init(int argc, const char *const *argv) return R; } +/* EXTPROTO */ +void +rxvt_init_signals () +{ +/* install exit handler for cleanup */ +#if 0 +#ifdef HAVE_ATEXIT + atexit(rxvt_clean_exit); +#else +# ifdef HAVE_ON_EXIT + on_exit(rxvt_clean_exit, NULL); /* non-ANSI exit handler */ +# endif +#endif +#endif + + struct sigaction sa; + + sigfillset (&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; + sa.sa_handler = rxvt_Exit_signal; sigaction (SIGHUP , &sa, 0); //TODO, also: SIGPIPE + sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); + sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); + sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); + sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); + +/* need to trap SIGURG for SVR4 (Unixware) rlogin */ +/* signal (SIGURG, SIG_DFL); */ + + XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); + //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); +} + bool rxvt_term::init (int argc, const char *const *argv) { @@ -134,9 +212,6 @@ rxvt_term::init (int argc, const char *const *argv) #if 0 #ifdef DEBUG_X XSynchronize(Xdisplay, True); - XSetErrorHandler((XErrorHandler) abort); -#else - XSetErrorHandler((XErrorHandler) rxvt_xerror_handler); #endif #endif @@ -180,18 +255,15 @@ rxvt_term::init (int argc, const char *const *argv) RETSIGTYPE rxvt_Child_signal(int sig __attribute__ ((unused))) { - dR; - int pid, save_errno = errno; - - do { - errno = 0; - } while ((pid = waitpid(-1, NULL, WNOHANG)) == -1 && errno == EINTR); + int pid, save_errno = errno; + while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) + ; + errno = save_errno; +#if 0 if (pid == R->cmd_pid) - exit(EXIT_SUCCESS); - - errno = save_errno; - signal(SIGCHLD, rxvt_Child_signal); + exit (EXIT_SUCCESS); +#endif } /* @@ -215,18 +287,20 @@ int rxvt_xerror_handler(const Display * display __attribute__ ((unused)), const XErrorEvent * event) { - dR; + dR; + + if (R->allowedxerror == -1) + R->allowedxerror = event->error_code; + else + { + rxvt_print_error("XError: Request: %d . %d, Error: %d", + event->request_code, event->minor_code, + event->error_code); - if (R->allowedxerror == -1) { - R->allowedxerror = event->error_code; - return 0; /* ignored anyway */ + R->destroy (); } - rxvt_print_error("XError: Request: %d . %d, Error: %d", - event->request_code, event->minor_code, - event->error_code); -/* XXX: probably should call rxvt_clean_exit() bypassing X routines */ - exit(EXIT_FAILURE); -/* NOTREACHED */ + + return 0; } /*----------------------------------------------------------------------*/ @@ -236,25 +310,11 @@ rxvt_xerror_handler(const Display * display */ /* EXTPROTO */ void -rxvt_clean_exit(void) +rxvt_clean_exit () { - dR; + dR; -#ifdef DEBUG_SCREEN - rxvt_scr_release(aR); -#endif -#ifndef NO_SETOWNER_TTYDEV - rxvt_privileged_ttydev(aR_ RESTORE); -#endif -#ifdef UTMP_SUPPORT - rxvt_privileged_utmp(aR_ RESTORE); -#endif -#ifdef USE_XIM - if (R->Input_Context != NULL) { - XDestroyIC(R->Input_Context); - R->Input_Context = NULL; - } -#endif + R->destroy (); } /* ------------------------------------------------------------------------- * diff --git a/src/rxvt.C b/src/rxvt.C
--- a/src/rxvt.C +++ b/src/rxvt.C @@ -7,6 +7,8 @@ int main(int argc, const char *const *argv) { + rxvt_init_signals (); + if (!rxvt_init(argc, argv)) return EXIT_FAILURE; diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h +++ b/src/rxvt.h @@ -1,5 +1,5 @@ /* - * $Id: rxvt.h,v 1.7 2003/11/26 10:42:34 pcg Exp $ + * $Id: rxvt.h,v 1.8 2003/11/27 10:12:10 pcg Exp $ */ #ifndef _RXVT_H_ /* include once only */ @@ -1115,6 +1115,8 @@ struct rxvt_term : rxvt_vars { unsigned char cmdbuf_base[BUFSIZ]; unsigned char kbuf[KBUFSZ]; + void destroy_cb (time_watcher &w); time_watcher destroy_ev; + void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; void x_cb (io_watcher &w, short revents); io_watcher x_ev; @@ -1132,6 +1134,7 @@ struct rxvt_term : rxvt_vars { rxvt_term (); ~rxvt_term (); + void destroy (); bool init (int argc, const char *const *argv); bool init_vars (); diff --git a/src/rxvtc.C b/src/rxvtc.C
--- a/src/rxvtc.C +++ b/src/rxvtc.C @@ -20,10 +20,11 @@ client::client () exit (EXIT_FAILURE); } + char *sockname = rxvt_connection::unix_sockname (); sockaddr_un sa; - sa.sun_family = AF_UNIX; - strcpy (sa.sun_path, rxvt_connection::unix_sockname ()); + strcpy (sa.sun_path, sockname); + free (sockname); if (connect (fd, (sockaddr *)&sa, sizeof (sa))) { diff --git a/src/rxvtd.C b/src/rxvtd.C
--- a/src/rxvtd.C +++ b/src/rxvtd.C @@ -8,6 +8,8 @@ #include <cstring> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> #include <sys/socket.h> #include <sys/un.h> @@ -28,16 +30,16 @@ struct server : rxvt_connection { void err (const char *format = 0, ...); }; -struct listener { +struct unix_listener { int fd; void accept_cb (io_watcher &w, short revents); io_watcher accept_ev; - listener (); + unix_listener (const char *sockname); }; -listener::listener () -: accept_ev (this, &listener::accept_cb) +unix_listener::unix_listener (const char *sockname) +: accept_ev (this, &unix_listener::accept_cb) { if ((fd = socket (PF_LOCAL, SOCK_STREAM, 0)) < 0) { @@ -48,16 +50,20 @@ listener::listener () sockaddr_un sa; sa.sun_family = AF_UNIX; - strcpy (sa.sun_path, rxvt_connection::unix_sockname ()); + strcpy (sa.sun_path, sockname); unlink (rxvt_connection::unix_sockname ()); + mode_t omask = umask (0077); + if (bind (fd, (sockaddr *)&sa, sizeof (sa))) { perror ("unable to bind listening socket"); exit (EXIT_FAILURE); } + umask (omask); + if (listen (fd, 5)) { perror ("unable to listen on socket"); @@ -67,7 +73,7 @@ listener::listener () accept_ev.start (fd, EVENT_READ); } -void listener::accept_cb (io_watcher &w, short revents) +void unix_listener::accept_cb (io_watcher &w, short revents) { int fd2 = accept (fd, 0, 0); @@ -147,16 +153,21 @@ void server::read_cb (io_watcher &w, short revents) int main(int argc, const char *const *argv) { - listener l; - { sigset_t ss; sigaddset (&ss, SIGHUP); + sigaddset (&ss, SIGPIPE); sigprocmask (SIG_BLOCK, &ss, 0); } - printf ("rxvtd running.\n"); + rxvt_init_signals (); + + char *sockname = rxvt_connection::unix_sockname (); + unix_listener l (sockname); + printf ("rxvtd listening on %s.\n", sockname); + free (sockname); + iom.loop (); #if 0 diff --git a/src/rxvtdaemon.C b/src/rxvtdaemon.C
--- a/src/rxvtdaemon.C +++ b/src/rxvtdaemon.C @@ -1,13 +1,32 @@ -#include <unistd.h> #include <stdint.h> #include <cstdlib> #include <cstring> +#include <unistd.h> +#include <sys/utsname.h> +#include <limits.h> + #include "rxvtdaemon.h" -const char *rxvt_connection::unix_sockname () +char *rxvt_connection::unix_sockname () { - return "/tmp/rxvtd~"; + char name[PATH_MAX]; + char *path = getenv ("RXVT_SOCKET"); + + if (!path) + { + struct utsname u; + uname (&u); + + path = getenv ("HOME"); + snprintf (name, PATH_MAX, "%s/.rxvt-%s", + path ? path : "/tmp", + u.nodename); + + path = name; + } + + return strdup (path); } void rxvt_connection::send (const char *data, int len) diff --git a/src/rxvtdaemon.h b/src/rxvtdaemon.h
--- a/src/rxvtdaemon.h +++ b/src/rxvtdaemon.h @@ -6,7 +6,7 @@ struct rxvt_connection { int fd; - static const char *unix_sockname (); + static char *unix_sockname (); void send (const char *data, int len); void send (const char *data); diff --git a/src/rxvtlib.h.in b/src/rxvtlib.h.in
--- a/src/rxvtlib.h.in +++ b/src/rxvtlib.h.in @@ -1,5 +1,5 @@ /* - * $Id: rxvtlib.h.in,v 1.3 2003/11/25 11:52:42 pcg Exp $ + * $Id: rxvtlib.h.in,v 1.4 2003/11/27 10:12:10 pcg Exp $ */ #ifndef _RXVTLIB_H_ /* include once only */ @@ -312,6 +312,7 @@ struct rxvt_vars { sstyle_t selection_style; }; +void rxvt_init_signals (); rxvt_t rxvt_init (int argc, const char *const *argv); #endif /* _RXVTLIB_H_ */ diff --git a/src/rxvtvec.h b/src/rxvtvec.h
--- a/src/rxvtvec.h +++ b/src/rxvtvec.h @@ -41,7 +41,7 @@ struct auto_ptr { auto_ptr() : p(0) { } auto_ptr(T *a) : p(a) { } - auto_ptr(auto_ptr &a) + auto_ptr(auto_ptr<T> &a) { p = a.p; a.p = 0;
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 12:42:33 2024