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

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