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.41 by root, Tue Dec 4 16:24:00 2007 UTC vs.
Revision 1.46 by root, Sun Jun 15 13:54:15 2008 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtd.C 2 * File: rxvtd.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
172 172
173 if (!strcmp (tok, "END")) 173 if (!strcmp (tok, "END"))
174 break; 174 break;
175 else if (!strcmp (tok, "ENV") && recv (tok)) 175 else if (!strcmp (tok, "ENV") && recv (tok))
176 envv->push_back (strdup (tok)); 176 envv->push_back (strdup (tok));
177 else if (!strcmp (tok, "CWD") && recv (tok))
178 {
179 if (chdir (tok))
180 {
181 delete envv;
182 delete argv;
183 return err ("unable to change to working directory to '%s', aborting: %s.\n",
184 (char *)tok, strerror (errno));
185 }
186 }
187 else if (!strcmp (tok, "ARG") && recv (tok)) 177 else if (!strcmp (tok, "ARG") && recv (tok))
188 argv->push_back (strdup (tok)); 178 argv->push_back (strdup (tok));
189 else 179 else
190 return err ("protocol error: unexpected NEW token.\n"); 180 return err ("protocol error: unexpected NEW token.\n");
191 } 181 }
196 rxvt_term *term = new rxvt_term; 186 rxvt_term *term = new rxvt_term;
197 187
198 term->log_hook = &log_cb; 188 term->log_hook = &log_cb;
199 term->getfd_hook = &getfd_cb; 189 term->getfd_hook = &getfd_cb;
200 190
201 bool success; 191 bool success = true;
202 192
203 try 193 try
204 { 194 {
205 success = term->init (argv, envv); 195 term->init (argv, envv);
206 } 196 }
207 catch (const class rxvt_failure_exception &e) 197 catch (const class rxvt_failure_exception &e)
208 { 198 {
209 success = false; 199 success = false;
210 } 200 }
211 201
212 term->log_hook = 0; 202 term->log_hook = 0;
213 203
214 chdir ("/"); 204 chdir ("/"); // init might change to different working directory
215 205
216 if (!success) 206 if (!success)
217 term->destroy (); 207 term->destroy ();
218 208
219 send ("END"); send (success ? 1 : 0); 209 send ("END"); send (success ? 1 : 0);
246 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); 236 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]);
247 return EXIT_FAILURE; 237 return EXIT_FAILURE;
248 } 238 }
249 } 239 }
250 240
251 chdir ("/"); 241 // optionally open display and never release it.
252
253 if (opt_opendisplay) 242 if (opt_opendisplay)
254 displays.get (getenv ("DISPLAY")); // open display and never release it 243 if (const char *dpy = getenv ("DISPLAY"))
244 displays.get (dpy ? dpy : ":0"); // move string logic into rxvt_display maybe?
255 245
256 char *sockname = rxvt_connection::unix_sockname (); 246 char *sockname = rxvt_connection::unix_sockname ();
257 unix_listener l (sockname); 247 unix_listener l (sockname);
248
249 chdir ("/");
258 250
259 if (!opt_quiet) 251 if (!opt_quiet)
260 { 252 {
261 printf ("rxvt-unicode daemon listening on %s.\n", sockname); 253 printf ("rxvt-unicode daemon listening on %s.\n", sockname);
262 fflush (stdout); 254 fflush (stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines