ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtc.C (file contents):
Revision 1.5 by pcg, Sat Nov 29 18:42:07 2003 UTC vs.
Revision 1.8 by pcg, Wed Mar 17 05:15:02 2004 UTC

1#include "../config.h"
1#include "rxvtdaemon.h" 2#include "rxvtdaemon.h"
2 3
3#include <cstdio> 4#include <cstdio>
4#include <cstdlib> 5#include <cstdlib>
5 6
34} 35}
35 36
36extern char **environ; 37extern char **environ;
37 38
38int 39int
39main(int argc, const char *const *argv) 40main (int argc, const char *const *argv)
40{ 41{
41 client c; 42 client c;
42 char buf[PATH_MAX]; 43 char buf[PATH_MAX];
43 44
44 { 45 {
45 sigset_t ss; 46 sigset_t ss;
46 47
48 sigemptyset (&ss);
47 sigaddset (&ss, SIGHUP); 49 sigaddset (&ss, SIGHUP);
48 sigprocmask (SIG_BLOCK, &ss, 0); 50 sigprocmask (SIG_BLOCK, &ss, 0);
49 } 51 }
50 52
51 c.send ("NEW"); 53 c.send ("NEW");
52 // instead of getcwd we could opendir(".") and pass the fd for fchdir *g* 54 // instead of getcwd we could opendir (".") and pass the fd for fchdir *g*
53 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); 55 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
54 56
55 for (char **var = environ; *environ; environ++) 57 for (char **var = environ; *environ; environ++)
56 c.send ("ENV"), c.send (*environ); 58 c.send ("ENV"), c.send (*environ);
57 59
58 for (int i = 0; i < argc; i++) 60 for (int i = 0; i < argc; i++)
59 c.send ("ARG"), c.send (argv[i]); 61 c.send ("ARG"), c.send (argv[i]);
60 62
61 c.send ("END"); 63 c.send ("END");
64
65 auto_str tok;
66
67 for (;;)
68 if (!c.recv (tok))
69 {
70 fprintf (stderr, "protocol error: unexpected eof from server.\n");
71 break;
72 }
73 else if (!strcmp (tok, "MSG") && c.recv (tok))
74 fprintf (stderr, "%s", (const char *)tok);
75 else if (!strcmp (tok, "END"))
76 {
77 int success;
78 if (c.recv (success))
79 exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
80 }
81 else
82 {
83 fprintf (stderr, "protocol error: received illegal token '%s'.\n", (const char *)tok);
84 break;
85 }
86
87 return EXIT_FAILURE;
62} 88}
63 89

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines