--- rxvt-unicode/src/rxvtc.C 2003/11/29 18:42:07 1.5 +++ 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]; @@ -44,12 +45,13 @@ { sigset_t ss; + sigemptyset (&ss); sigaddset (&ss, SIGHUP); sigprocmask (SIG_BLOCK, &ss, 0); } 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++) @@ -59,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; }