--- rxvt-unicode/src/rxvtc.C 2003/12/02 21:49:46 1.6 +++ rxvt-unicode/src/rxvtc.C 2004/03/17 05:15:02 1.8 @@ -1,3 +1,4 @@ +#include "../config.h" #include "rxvtdaemon.h" #include @@ -36,7 +37,7 @@ extern char **environ; int -main(int argc, const char *const *argv) +main (int argc, const char *const *argv) { client c; char buf[PATH_MAX]; @@ -50,7 +51,7 @@ } c.send ("NEW"); - // instead of getcwd we could opendir(".") and pass the fd for fchdir *g* + // instead of getcwd we could opendir (".") and pass the fd for fchdir *g* c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); for (char **var = environ; *environ; environ++) @@ -60,5 +61,29 @@ c.send ("ARG"), c.send (argv[i]); c.send ("END"); + + auto_str tok; + + for (;;) + if (!c.recv (tok)) + { + fprintf (stderr, "protocol error: unexpected eof from server.\n"); + break; + } + else if (!strcmp (tok, "MSG") && c.recv (tok)) + fprintf (stderr, "%s", (const char *)tok); + else if (!strcmp (tok, "END")) + { + int success; + if (c.recv (success)) + exit (success ? EXIT_SUCCESS : EXIT_FAILURE); + } + else + { + fprintf (stderr, "protocol error: received illegal token '%s'.\n", (const char *)tok); + break; + } + + return EXIT_FAILURE; }