2939 perror(
"Failed to send targets to server");
2942 if (targets.empty()) exit(EXIT_SUCCESS);
2947 struct sockaddr_in socket_addr;
2948 socket_fd = socket(AF_INET, SOCK_STREAM, 0);
2950 socket_addr.sin_family = AF_INET;
2951 socket_addr.sin_addr.s_addr = inet_addr(
"127.0.0.1");
2953 if (connect(
socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(sockaddr_in)))
2956 struct sockaddr_un socket_addr;
2958 if (len >=
sizeof(socket_addr.sun_path) - 1) exit(EXIT_FAILURE);
2959 socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
2961 socket_addr.sun_family = AF_UNIX;
2963 if (connect(
socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(socket_addr.sun_family) + len))
2967 if (setsockopt(
socket_fd, SOL_SOCKET, SO_NOSIGPIPE, &set_option,
sizeof(set_option)))
2973 char *
id = getenv(
"REMAKE_JOB_ID");
2974 int job_id =
id ? atoi(
id) : -1;
2975 if (send(
socket_fd, (
char *)&job_id,
sizeof(job_id), MSG_NOSIGNAL) !=
sizeof(job_id))
2979 for (string_list::const_iterator i = targets.begin(),
2980 i_end = targets.end(); i != i_end; ++i)
2982 DEBUG_open <<
"Sending target " << *i <<
"... ";
2983 std::string s =
'T' + *i;
2984 ssize_t len = s.length() + 1;
2985 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2990 for (variable_map::const_iterator i =
variables.begin(),
2991 i_end =
variables.end(); i != i_end; ++i)
2993 DEBUG_open <<
"Sending variable " << i->first <<
"... ";
2994 std::string s =
'V' + i->first;
2995 ssize_t len = s.length() + 1;
2996 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2998 for (string_list::const_iterator j = i->second.begin(),
2999 j_end = i->second.end(); j != j_end; ++j)
3001 std::string s =
'W' + *j;
3002 len = s.length() + 1;
3003 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
3010 if (send(
socket_fd, &result, 1, MSG_NOSIGNAL) != 1)
goto error;
3011 if (recv(
socket_fd, &result, 1, 0) != 1) exit(EXIT_FAILURE);
3012 exit(result ? EXIT_SUCCESS : EXIT_FAILURE);