ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
Revision: 1.5
Committed: Sat Nov 29 18:42:07 2003 UTC (20 years, 5 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -2 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     sigaddset (&ss, SIGHUP);
48     sigprocmask (SIG_BLOCK, &ss, 0);
49     }
50    
51 pcg 1.1 c.send ("NEW");
52     // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
53 pcg 1.2 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
54 pcg 1.3
55     for (char **var = environ; *environ; environ++)
56     c.send ("ENV"), c.send (*environ);
57 pcg 1.1
58     for (int i = 0; i < argc; i++)
59 pcg 1.2 c.send ("ARG"), c.send (argv[i]);
60    
61 pcg 1.1 c.send ("END");
62     }
63