… | |
… | |
2 | |
2 | |
3 | #include <cstdio> |
3 | #include <cstdio> |
4 | #include <cstdlib> |
4 | #include <cstdlib> |
5 | |
5 | |
6 | #include <unistd.h> |
6 | #include <unistd.h> |
|
|
7 | #include <signal.h> |
7 | #include <sys/socket.h> |
8 | #include <sys/socket.h> |
8 | #include <sys/un.h> |
9 | #include <sys/un.h> |
9 | |
10 | |
10 | struct client : rxvt_connection { |
11 | struct client : rxvt_connection { |
11 | client (); |
12 | client (); |
… | |
… | |
29 | perror ("unable to bind listening socket"); |
30 | perror ("unable to bind listening socket"); |
30 | exit (EXIT_FAILURE); |
31 | exit (EXIT_FAILURE); |
31 | } |
32 | } |
32 | } |
33 | } |
33 | |
34 | |
|
|
35 | extern char **environ; |
|
|
36 | |
34 | int |
37 | int |
35 | main(int argc, const char *const *argv) |
38 | main(int argc, const char *const *argv) |
36 | { |
39 | { |
37 | client c; |
40 | client c; |
38 | char buf[PATH_MAX]; |
41 | char buf[PATH_MAX]; |
39 | |
42 | |
|
|
43 | { |
|
|
44 | sigset_t ss; |
|
|
45 | |
|
|
46 | sigaddset (&ss, SIGHUP); |
|
|
47 | sigprocmask (SIG_BLOCK, &ss, 0); |
|
|
48 | } |
|
|
49 | |
40 | c.send ("NEW"); |
50 | c.send ("NEW"); |
41 | c.send ("DISPLAY"); c.send (getenv ("DISPLAY")); |
|
|
42 | // instead of getcwd we could opendir(".") and pass the fd for fchdir *g* |
51 | // instead of getcwd we could opendir(".") and pass the fd for fchdir *g* |
43 | c.send ("CWD"); c.send (getcwd (buf, sizeof (buf))); |
52 | c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); |
44 | |
53 | |
45 | c.send ("ARGV"); c.send (argc); |
54 | for (char **var = environ; *environ; environ++) |
|
|
55 | c.send ("ENV"), c.send (*environ); |
|
|
56 | |
46 | for (int i = 0; i < argc; i++) |
57 | for (int i = 0; i < argc; i++) |
47 | c.send (argv[i]); |
58 | c.send ("ARG"), c.send (argv[i]); |
|
|
59 | |
48 | c.send ("END"); |
60 | c.send ("END"); |
49 | } |
61 | } |
50 | |
62 | |