ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
Revision: 1.3
Committed: Tue Nov 25 11:52:42 2003 UTC (20 years, 6 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +13 -1 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 listening socket");
20 exit (EXIT_FAILURE);
21 }
22
23 sockaddr_un sa;
24
25 sa.sun_family = AF_UNIX;
26 strcpy (sa.sun_path, rxvt_connection::unix_sockname ());
27
28 if (connect (fd, (sockaddr *)&sa, sizeof (sa)))
29 {
30 perror ("unable to bind listening socket");
31 exit (EXIT_FAILURE);
32 }
33 }
34
35 extern char **environ;
36
37 int
38 main(int argc, const char *const *argv)
39 {
40 client c;
41 char buf[PATH_MAX];
42
43 {
44 sigset_t ss;
45
46 sigaddset (&ss, SIGHUP);
47 sigprocmask (SIG_BLOCK, &ss, 0);
48 }
49
50 c.send ("NEW");
51 // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
52 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
53
54 for (char **var = environ; *environ; environ++)
55 c.send ("ENV"), c.send (*environ);
56
57 for (int i = 0; i < argc; i++)
58 c.send ("ARG"), c.send (argv[i]);
59
60 c.send ("END");
61 }
62