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.9 by pcg, Fri Apr 2 20:41:01 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines