ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
Revision: 1.6
Committed: Tue Dec 2 21:49:46 2003 UTC (20 years, 5 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-1-3, rel-1-2, before_astyle, after_astyle
Changes since 1.5: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 #include "rxvtdaemon.h"
2    
3     #include <cstdio>
4     #include <cstdlib>
5    
6     #include <unistd.h>
7 pcg 1.3 #include <signal.h>
8 pcg 1.1 #include <sys/socket.h>
9     #include <sys/un.h>
10    
11     struct client : rxvt_connection {
12     client ();
13     };
14    
15     client::client ()
16     {
17     if ((fd = socket (PF_LOCAL, SOCK_STREAM, 0)) < 0)
18     {
19 pcg 1.5 perror ("unable to create communications socket");
20 pcg 1.1 exit (EXIT_FAILURE);
21     }
22    
23 pcg 1.4 char *sockname = rxvt_connection::unix_sockname ();
24 pcg 1.1 sockaddr_un sa;
25     sa.sun_family = AF_UNIX;
26 pcg 1.4 strcpy (sa.sun_path, sockname);
27     free (sockname);
28 pcg 1.1
29     if (connect (fd, (sockaddr *)&sa, sizeof (sa)))
30     {
31 pcg 1.5 perror ("unable to connect to rxvtd");
32 pcg 1.1 exit (EXIT_FAILURE);
33     }
34     }
35    
36 pcg 1.3 extern char **environ;
37    
38 pcg 1.1 int
39     main(int argc, const char *const *argv)
40     {
41     client c;
42     char buf[PATH_MAX];
43    
44 pcg 1.3 {
45     sigset_t ss;
46    
47 pcg 1.6 sigemptyset (&ss);
48 pcg 1.3 sigaddset (&ss, SIGHUP);
49     sigprocmask (SIG_BLOCK, &ss, 0);
50     }
51    
52 pcg 1.1 c.send ("NEW");
53     // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
54 pcg 1.2 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
55 pcg 1.3
56     for (char **var = environ; *environ; environ++)
57     c.send ("ENV"), c.send (*environ);
58 pcg 1.1
59     for (int i = 0; i < argc; i++)
60 pcg 1.2 c.send ("ARG"), c.send (argv[i]);
61    
62 pcg 1.1 c.send ("END");
63     }
64