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

Comparing rxvt-unicode/src/rxvtd.C (file contents):
Revision 1.30 by root, Wed Aug 9 22:01:07 2006 UTC vs.
Revision 1.33 by ayin, Wed Oct 31 09:55:24 2007 UTC

70 70
71unix_listener::unix_listener (const char *sockname) 71unix_listener::unix_listener (const char *sockname)
72: accept_ev (this, &unix_listener::accept_cb) 72: accept_ev (this, &unix_listener::accept_cb)
73{ 73{
74 sockaddr_un sa; 74 sockaddr_un sa;
75 75
76 if (strlen(sockname) >= sizeof(sa.sun_path)) 76 if (strlen (sockname) >= sizeof(sa.sun_path))
77 {
77 rxvt_fatal ("socket name too long, aborting.\n"); 78 fputs ("socket name too long, aborting.\n", stderr);
79 exit (EXIT_FAILURE);
80 }
78 81
79 if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 82 if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
80 { 83 {
81 perror ("unable to create listening socket"); 84 perror ("unable to create listening socket");
82 exit (EXIT_FAILURE); 85 exit (EXIT_FAILURE);
140 va_list ap; 143 va_list ap;
141 va_start (ap, format); 144 va_start (ap, format);
142 vsnprintf (err, 1024, format, ap); 145 vsnprintf (err, 1024, format, ap);
143 va_end (ap); 146 va_end (ap);
144 147
145 send ("MSG"), send (err); 148 log_msg (err);
146 } 149 }
147 150
148 send ("END", 0); 151 send ("END"), send (0);
149 close (fd); 152 close (fd);
150 delete this; 153 delete this;
151} 154}
152 155
153void server::read_cb (io_watcher &w, short revents) 156void server::read_cb (io_watcher &w, short revents)
158 { 161 {
159 if (!strcmp (tok, "NEW")) 162 if (!strcmp (tok, "NEW"))
160 { 163 {
161 stringvec *argv = new stringvec; 164 stringvec *argv = new stringvec;
162 stringvec *envv = new stringvec; 165 stringvec *envv = new stringvec;
163 166
164 for (;;) 167 for (;;)
165 { 168 {
166 if (!recv (tok)) 169 if (!recv (tok))
167 return err (); 170 return err ();
168 171
171 else if (!strcmp (tok, "ENV") && recv (tok)) 174 else if (!strcmp (tok, "ENV") && recv (tok))
172 envv->push_back (strdup (tok)); 175 envv->push_back (strdup (tok));
173 else if (!strcmp (tok, "CWD") && recv (tok)) 176 else if (!strcmp (tok, "CWD") && recv (tok))
174 { 177 {
175 if (chdir (tok)) 178 if (chdir (tok))
179 {
180 delete envv;
181 delete argv;
176 err ("unable to change to working directory to '%s': %s", 182 return err ("unable to change to working directory to '%s', aborting: %s.\n",
177 (char *)tok, strerror (errno)); 183 (char *)tok, strerror (errno));
184 }
178 } 185 }
179 else if (!strcmp (tok, "ARG") && recv (tok)) 186 else if (!strcmp (tok, "ARG") && recv (tok))
180 argv->push_back (strdup (tok)); 187 argv->push_back (strdup (tok));
181 else 188 else
182 return err ("protocol error: unexpected NEW token"); 189 return err ("protocol error: unexpected NEW token.\n");
183 } 190 }
184 191
185 envv->push_back (0); 192 envv->push_back (0);
186 193
187 { 194 {
188 rxvt_term *term = new rxvt_term; 195 rxvt_term *term = new rxvt_term;
189 196
190 term->log_hook = &log_cb; 197 term->log_hook = &log_cb;
191 term->getfd_hook = &getfd_cb; 198 term->getfd_hook = &getfd_cb;
192 199
193 bool success; 200 bool success;
194 201
195 try 202 try
196 { 203 {
197 success = term->init (argv, envv); 204 success = term->init (argv, envv);
198 } 205 }
199 catch (const class rxvt_failure_exception &e) 206 catch (const class rxvt_failure_exception &e)
210 217
211 send ("END"); send (success ? 1 : 0); 218 send ("END"); send (success ? 1 : 0);
212 } 219 }
213 } 220 }
214 else 221 else
215 return err ("protocol error: request '%s' unsupported.", (char *)tok); 222 return err ("protocol error: request '%s' unsupported.\n", (char *)tok);
216 } 223 }
217 else 224 else
218 return err (); 225 return err ();
219} 226}
220 227
237 { 244 {
238 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); 245 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]);
239 return EXIT_FAILURE; 246 return EXIT_FAILURE;
240 } 247 }
241 } 248 }
242 249
243 chdir ("/"); 250 chdir ("/");
244 251
245 if (opt_opendisplay) 252 if (opt_opendisplay)
246 displays.get (getenv ("DISPLAY")); // open display and never release it 253 displays.get (getenv ("DISPLAY")); // open display and never release it
247 254

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines