… | |
… | |
26 | #include "rxvt.h" |
26 | #include "rxvt.h" |
27 | |
27 | |
28 | #include <cstdio> |
28 | #include <cstdio> |
29 | #include <cstdlib> |
29 | #include <cstdlib> |
30 | #include <cstring> |
30 | #include <cstring> |
|
|
31 | #include <csignal> |
31 | |
32 | |
32 | #include <unistd.h> |
33 | #include <unistd.h> |
33 | #include <signal.h> |
|
|
34 | #include <sys/socket.h> |
34 | #include <sys/socket.h> |
35 | #include <sys/un.h> |
35 | #include <sys/un.h> |
36 | |
36 | |
37 | struct client : rxvt_connection { |
37 | struct client : rxvt_connection { |
38 | client (); |
38 | client (); |
… | |
… | |
63 | |
63 | |
64 | int |
64 | int |
65 | main (int argc, const char *const *argv) |
65 | main (int argc, const char *const *argv) |
66 | { |
66 | { |
67 | client c; |
67 | client c; |
68 | char buf[PATH_MAX]; |
|
|
69 | |
|
|
70 | { |
68 | { |
71 | sigset_t ss; |
69 | sigset_t ss; |
72 | |
70 | |
73 | sigemptyset (&ss); |
71 | sigemptyset (&ss); |
74 | sigaddset (&ss, SIGHUP); |
72 | sigaddset (&ss, SIGHUP); |
75 | sigprocmask (SIG_BLOCK, &ss, 0); |
73 | sigprocmask (SIG_BLOCK, &ss, 0); |
76 | } |
74 | } |
77 | |
75 | |
78 | c.send ("NEW"); |
76 | c.send ("NEW"); |
|
|
77 | |
79 | // instead of getcwd we could opendir (".") and pass the fd for fchdir *g* |
78 | // instead of getcwd we could opendir (".") and pass the fd for fchdir *g* |
80 | c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); |
79 | char cwd[PATH_MAX]; |
|
|
80 | |
|
|
81 | if (!getcwd (cwd, sizeof (cwd))) |
|
|
82 | { |
|
|
83 | perror ("unable to determine current working directory"); |
|
|
84 | exit (EXIT_FAILURE); |
|
|
85 | } |
|
|
86 | |
|
|
87 | c.send ("CWD"), c.send (cwd); |
81 | |
88 | |
82 | for (char **var = environ; *environ; environ++) |
89 | for (char **var = environ; *environ; environ++) |
83 | c.send ("ENV"), c.send (*environ); |
90 | c.send ("ENV"), c.send (*environ); |
84 | |
91 | |
85 | const char *base = strrchr (argv[0], '/'); |
92 | const char *base = strrchr (argv[0], '/'); |