From 17bf2b2098f166747871691089216d5c228554bf Mon Sep 17 00:00:00 2001 From: root Date: Wed, 1 Feb 2006 18:07:18 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 1 + doc/rxvtc.1.pod | 10 ++++++++++ src/optinc.h | 2 ++ src/rsinc.h | 2 +- src/rxvtc.C | 16 ++++++++++------ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 3bf05937..706c3370 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,7 @@ TODO: rxvt -bg #comment - changed interpretation of [alpha] colour prefix. - +option now really sets the option to default, instead of using the resource value. + - use exit status 2 in urxvtc when urxvtd couldn't be contacted. - the linux yield hack is back, now using usleep, and enabled only on __linux__. - further round trip eliminations in the !XFT case by remembering diff --git a/doc/rxvtc.1.pod b/doc/rxvtc.1.pod index 871efaf4..81d3b070 100644 --- a/doc/rxvtc.1.pod +++ b/doc/rxvtc.1.pod @@ -21,6 +21,16 @@ B<@@RXVT_NAME@@c>, too. Please note that all options are currently interpreted in the context of the daemon process, which makes a difference for options that specify a file descriptor (such as B<-pty-fd>). +=head1 EXIT STATUS + +If everything went well, @@RXVT_NAME@@c returns with an exit status of C<0>. +If contacting the daemon fails, it exits with the exit status C<2>. In all other error +cases it returns with status C<1>. + +This can be used to implement auto-starting behaviour, by checking for an +exit status of C<2>, running C<@@RXVT_NAME@@d -f -q> and retrying the call +to @@RXVT_NAME@@c. + =head1 ENVIRONMENT All environment variables of the current process will be made available diff --git a/src/optinc.h b/src/optinc.h index fee0e084..a3c40431 100644 --- a/src/optinc.h +++ b/src/optinc.h @@ -1,3 +1,5 @@ +// all resource indices, used by rxvtlib.h and rxvtperl.xs + def(console, 0) def(loginShell, 1) def(iconic, 2) diff --git a/src/rsinc.h b/src/rsinc.h index 066c5c93..2ecec020 100644 --- a/src/rsinc.h +++ b/src/rsinc.h @@ -1,4 +1,4 @@ -// all resource indices, used by rxvt.h anf rxvtperl.xs +// all resource indices, used by rxvt.h and rxvtperl.xs def (display_name) def (term_name) diff --git a/src/rxvtc.C b/src/rxvtc.C index 0dd2d1c7..e43d04c0 100644 --- a/src/rxvtc.C +++ b/src/rxvtc.C @@ -35,6 +35,10 @@ #include "rxvt.h" +#define STATUS_SUCCESS 0 +#define STATUS_FAILURE 1 +#define STATUS_CONNECTION_FAILED 2 + struct client : rxvt_connection { client (); }; @@ -44,7 +48,7 @@ client::client () if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) { perror ("unable to create communications socket"); - exit (EXIT_FAILURE); + exit (STATUS_FAILURE); } char *sockname = rxvt_connection::unix_sockname (); @@ -56,7 +60,7 @@ client::client () if (connect (fd, (sockaddr *)&sa, sizeof (sa))) { perror ("unable to connect to the rxvt-unicode daemon"); - exit (EXIT_FAILURE); + exit (STATUS_CONNECTION_FAILED); } } @@ -82,7 +86,7 @@ main (int argc, const char *const *argv) if (!getcwd (cwd, sizeof (cwd))) { perror ("unable to determine current working directory"); - exit (EXIT_FAILURE); + exit (STATUS_FAILURE); } c.send ("CWD"), c.send (cwd); @@ -115,7 +119,7 @@ main (int argc, const char *const *argv) if (!ptytty::send_fd (c.fd, cint)) { fprintf (stderr, "unable to send fd %d: ", cint); perror (0); - exit (EXIT_FAILURE); + exit (STATUS_FAILURE); } } else if (!strcmp (tok, "END")) @@ -123,7 +127,7 @@ main (int argc, const char *const *argv) int success; if (c.recv (success)) - exit (success ? EXIT_SUCCESS : EXIT_FAILURE); + exit (success ? STATUS_SUCCESS : STATUS_FAILURE); } else { @@ -131,6 +135,6 @@ main (int argc, const char *const *argv) break; } - return EXIT_FAILURE; + return STATUS_FAILURE; } -- 2.34.1