1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtc.C |
2 | * File: rxvtc.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
… | |
… | |
43 | client (); |
43 | client (); |
44 | }; |
44 | }; |
45 | |
45 | |
46 | client::client () |
46 | client::client () |
47 | { |
47 | { |
|
|
48 | sockaddr_un sa; |
|
|
49 | char *sockname = rxvt_connection::unix_sockname (); |
|
|
50 | |
|
|
51 | if (strlen(sockname) >= sizeof(sa.sun_path)) |
|
|
52 | { |
|
|
53 | fputs ("socket name too long, aborting.\n", stderr); |
|
|
54 | exit (STATUS_FAILURE); |
|
|
55 | } |
|
|
56 | |
48 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
57 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
49 | { |
58 | { |
50 | perror ("unable to create communications socket"); |
59 | perror ("unable to create communications socket"); |
51 | exit (STATUS_FAILURE); |
60 | exit (STATUS_FAILURE); |
52 | } |
61 | } |
53 | |
62 | |
54 | char *sockname = rxvt_connection::unix_sockname (); |
|
|
55 | sockaddr_un sa; |
|
|
56 | sa.sun_family = AF_UNIX; |
63 | sa.sun_family = AF_UNIX; |
57 | strcpy (sa.sun_path, sockname); |
64 | strcpy (sa.sun_path, sockname); |
58 | free (sockname); |
65 | free (sockname); |
59 | |
66 | |
60 | if (connect (fd, (sockaddr *)&sa, sizeof (sa))) |
67 | if (connect (fd, (sockaddr *)&sa, sizeof (sa))) |
… | |
… | |
73 | { |
80 | { |
74 | sigset_t ss; |
81 | sigset_t ss; |
75 | |
82 | |
76 | sigemptyset (&ss); |
83 | sigemptyset (&ss); |
77 | sigaddset (&ss, SIGHUP); |
84 | sigaddset (&ss, SIGHUP); |
|
|
85 | sigaddset (&ss, SIGPIPE); |
78 | sigprocmask (SIG_BLOCK, &ss, 0); |
86 | sigprocmask (SIG_BLOCK, &ss, 0); |
79 | } |
87 | } |
80 | |
88 | |
81 | c.send ("NEW"); |
89 | c.send ("NEW"); |
82 | |
90 | |