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

Comparing rxvt-unicode/src/rxvtdaemon.C (file contents):
Revision 1.8 by root, Wed Aug 18 00:34:27 2004 UTC vs.
Revision 1.9 by root, Sun Dec 25 15:30:29 2005 UTC

24#include <cstring> 24#include <cstring>
25#include <cstdio> 25#include <cstdio>
26 26
27#include <inttypes.h> 27#include <inttypes.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <errno.h>
30#include <sys/types.h>
29#include <sys/utsname.h> 31#include <sys/utsname.h>
30#include <limits.h> 32#include <limits.h>
31 33
32#include "rxvtdaemon.h" 34#include "rxvtdaemon.h"
35
36// works around linux kernel bug, returns EAGAIN on a blocking socket
37static ssize_t
38read_ (int fd, void *buf, size_t count)
39{
40 int ret;
41
42 do
43 ret = read (fd, buf, count);
44 while (ret < 0 && errno == EAGAIN);
45
46 return ret;
47}
33 48
34char *rxvt_connection::unix_sockname () 49char *rxvt_connection::unix_sockname ()
35{ 50{
36 char name[PATH_MAX]; 51 char name[PATH_MAX];
37 char *path = getenv ("RXVT_SOCKET"); 52 char *path = getenv ("RXVT_SOCKET");
70bool rxvt_connection::recv (auto_str &data, int *len) 85bool rxvt_connection::recv (auto_str &data, int *len)
71{ 86{
72 uint8_t s[2]; 87 uint8_t s[2];
73 int l; 88 int l;
74 89
75 if (read (fd, s, 2) != 2) 90 if (read_ (fd, s, 2) != 2)
76 return false; 91 return false;
77 92
78 l = (s[0] << 8) + s[1]; 93 l = (s[0] << 8) + s[1];
79 if (l > 4096) 94 if (l > 4096)
80 return false; 95 return false;
85 data = new char[l + 1]; 100 data = new char[l + 1];
86 101
87 if (!data) 102 if (!data)
88 return false; 103 return false;
89 104
90 if (read (fd, data, l) != l) 105 if (read_ (fd, data, l) != l)
91 return false; 106 return false;
92 107
93 data[l] = 0; 108 data[l] = 0;
94 109
95 return true; 110 return true;
106 121
107bool rxvt_connection::recv (int &data) 122bool rxvt_connection::recv (int &data)
108{ 123{
109 uint8_t s[4]; 124 uint8_t s[4];
110 125
111 if (read (fd, s, 4) != 4) 126 if (read_ (fd, s, 4) != 4)
112 return false; 127 return false;
113 128
114 data = (((((s[0] << 8) | s[1]) << 8) | s[2]) << 8) | s[3]; 129 data = (((((s[0] << 8) | s[1]) << 8) | s[2]) << 8) | s[3];
115 130
116 return true; 131 return true;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines