OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The Chromium Authors. All rights reserved. | 2 * Copyright 2015 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 17 matching lines...) Expand all Loading... |
28 struct sockaddr_un server_addr; | 28 struct sockaddr_un server_addr; |
29 init_memtrack_server_addr(&server_addr); | 29 init_memtrack_server_addr(&server_addr); |
30 | 30 |
31 if (connect(sock, (struct sockaddr*)&server_addr, sizeof(server_addr))) | 31 if (connect(sock, (struct sockaddr*)&server_addr, sizeof(server_addr))) |
32 exit_with_failure("connect"); | 32 exit_with_failure("connect"); |
33 | 33 |
34 if (send(sock, pid, strlen(pid) + 1, 0) < 0) | 34 if (send(sock, pid, strlen(pid) + 1, 0) < 0) |
35 exit_with_failure("send"); | 35 exit_with_failure("send"); |
36 | 36 |
37 char buf[4096]; | 37 char buf[4096]; |
38 memset(buf, 0, sizeof(buf)); | 38 ssize_t rsize = recv(sock, buf, sizeof(buf) - 1, 0); |
39 if (recv(sock, buf, sizeof(buf), 0) <= 0) | 39 if (rsize < 0) |
40 exit_with_failure("recv"); | 40 exit_with_failure("recv"); |
| 41 buf[rsize] = '\0'; |
41 | 42 |
42 puts(buf); | 43 puts(buf); |
43 return EXIT_SUCCESS; | 44 return EXIT_SUCCESS; |
44 } | 45 } |
OLD | NEW |