-int ustcomm_request_consumer(pid_t pid, const char *channel)
-{
- int result, daemon_fd;
- int retval = 0;
- char *msg=NULL;
- char *explicit_daemon_socket_path, *daemon_path;
-
- explicit_daemon_socket_path = getenv("UST_DAEMON_SOCKET");
- if (explicit_daemon_socket_path) {
- /* user specified explicitly a socket path */
- result = asprintf(&daemon_path, "%s", explicit_daemon_socket_path);
- } else {
- /* just use the default path */
- result = asprintf(&daemon_path, "%s/ustd", SOCK_DIR);
- }
- if (result < 0) {
- ERR("string overflow allocating socket name");
- return -1;
+ result = recv(sock, &peek_header, sizeof(peek_header),
+ MSG_PEEK | MSG_WAITALL);
+ if (result <= 0) {
+ if(errno == ECONNRESET) {
+ return 0;
+ } else if (errno == EINTR) {
+ return -1;
+ } else if (result < 0) {
+ PERROR("recv");
+ return -1;
+ }
+ return 0;