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.11 by pcg, Thu Apr 8 20:31:45 2004 UTC vs.
Revision 1.15 by root, Mon Feb 14 20:46:47 2005 UTC

25 25
26#include "rxvt.h" 26#include "rxvt.h"
27 27
28#include <cstdio> 28#include <cstdio>
29#include <cstdlib> 29#include <cstdlib>
30#include <cstring>
31#include <csignal>
30 32
31#include <unistd.h> 33#include <unistd.h>
32#include <signal.h>
33#include <sys/socket.h> 34#include <sys/socket.h>
34#include <sys/un.h> 35#include <sys/un.h>
35 36
36struct client : rxvt_connection { 37struct client : rxvt_connection {
37 client (); 38 client ();
51 strcpy (sa.sun_path, sockname); 52 strcpy (sa.sun_path, sockname);
52 free (sockname); 53 free (sockname);
53 54
54 if (connect (fd, (sockaddr *)&sa, sizeof (sa))) 55 if (connect (fd, (sockaddr *)&sa, sizeof (sa)))
55 { 56 {
56 perror ("unable to connect to rxvtd"); 57 perror ("unable to connect to the rxvt-unicode daemon");
57 exit (EXIT_FAILURE); 58 exit (EXIT_FAILURE);
58 } 59 }
59} 60}
60 61
61extern char **environ; 62extern char **environ;
62 63
63int 64int
64main (int argc, const char *const *argv) 65main (int argc, const char *const *argv)
65{ 66{
66 client c; 67 client c;
67 char buf[PATH_MAX];
68
69 { 68 {
70 sigset_t ss; 69 sigset_t ss;
71 70
72 sigemptyset (&ss); 71 sigemptyset (&ss);
73 sigaddset (&ss, SIGHUP); 72 sigaddset (&ss, SIGHUP);
74 sigprocmask (SIG_BLOCK, &ss, 0); 73 sigprocmask (SIG_BLOCK, &ss, 0);
75 } 74 }
76 75
77 c.send ("NEW"); 76 c.send ("NEW");
77
78 // instead of getcwd we could opendir (".") and pass the fd for fchdir *g* 78 // instead of getcwd we could opendir (".") and pass the fd for fchdir *g*
79 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); 79 char cwd[PATH_MAX];
80
81 if (!getcwd (cwd, sizeof (cwd)))
82 {
83 perror ("unable to determine current working directory");
84 exit (EXIT_FAILURE);
85 }
86
87 c.send ("CWD"), c.send (cwd);
80 88
81 for (char **var = environ; *environ; environ++) 89 for (char **var = environ; *environ; environ++)
82 c.send ("ENV"), c.send (*environ); 90 c.send ("ENV"), c.send (*environ);
83 91
92 const char *base = strrchr (argv[0], '/');
93 base = base ? base + 1 : argv[0];
94 c.send ("ARG"), c.send (strcmp (base, RXVTNAME "c") ? base : RXVTNAME);
95
84 for (int i = 0; i < argc; i++) 96 for (int i = 1; i < argc; i++)
85 c.send ("ARG"), c.send (argv[i]); 97 c.send ("ARG"), c.send (argv[i]);
86 98
87 c.send ("END"); 99 c.send ("END");
88 100
89 auto_str tok; 101 auto_str tok;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines