ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtc.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtc.C (file contents):
Revision 1.2 by pcg, Mon Nov 24 19:52:16 2003 UTC vs.
Revision 1.6 by pcg, Tue Dec 2 21:49:46 2003 UTC

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
10struct client : rxvt_connection { 11struct client : rxvt_connection {
11 client (); 12 client ();
13 14
14client::client () 15client::client ()
15{ 16{
16 if ((fd = socket (PF_LOCAL, SOCK_STREAM, 0)) < 0) 17 if ((fd = socket (PF_LOCAL, SOCK_STREAM, 0)) < 0)
17 { 18 {
18 perror ("unable to create listening socket"); 19 perror ("unable to create communications socket");
19 exit (EXIT_FAILURE); 20 exit (EXIT_FAILURE);
20 } 21 }
21 22
23 char *sockname = rxvt_connection::unix_sockname ();
22 sockaddr_un sa; 24 sockaddr_un sa;
23
24 sa.sun_family = AF_UNIX; 25 sa.sun_family = AF_UNIX;
25 strcpy (sa.sun_path, rxvt_connection::unix_sockname ()); 26 strcpy (sa.sun_path, sockname);
27 free (sockname);
26 28
27 if (connect (fd, (sockaddr *)&sa, sizeof (sa))) 29 if (connect (fd, (sockaddr *)&sa, sizeof (sa)))
28 { 30 {
29 perror ("unable to bind listening socket"); 31 perror ("unable to connect to rxvtd");
30 exit (EXIT_FAILURE); 32 exit (EXIT_FAILURE);
31 } 33 }
32} 34}
35
36extern char **environ;
33 37
34int 38int
35main(int argc, const char *const *argv) 39main(int argc, const char *const *argv)
36{ 40{
37 client c; 41 client c;
38 char buf[PATH_MAX]; 42 char buf[PATH_MAX];
39 43
44 {
45 sigset_t ss;
46
47 sigemptyset (&ss);
48 sigaddset (&ss, SIGHUP);
49 sigprocmask (SIG_BLOCK, &ss, 0);
50 }
51
40 c.send ("NEW"); 52 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* 53 // instead of getcwd we could opendir(".") and pass the fd for fchdir *g*
43 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf))); 54 c.send ("CWD"), c.send (getcwd (buf, sizeof (buf)));
55
56 for (char **var = environ; *environ; environ++)
57 c.send ("ENV"), c.send (*environ);
44 58
45 for (int i = 0; i < argc; i++) 59 for (int i = 0; i < argc; i++)
46 c.send ("ARG"), c.send (argv[i]); 60 c.send ("ARG"), c.send (argv[i]);
47 61
48 c.send ("END"); 62 c.send ("END");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines