2870 perror(
"Failed to send targets to server");
2873 if (targets.empty()) exit(EXIT_SUCCESS);
2878 struct sockaddr_in socket_addr;
2879 socket_fd = socket(AF_INET, SOCK_STREAM, 0);
2881 socket_addr.sin_family = AF_INET;
2882 socket_addr.sin_addr.s_addr = inet_addr(
"127.0.0.1");
2884 if (connect(
socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(sockaddr_in)))
2887 struct sockaddr_un socket_addr;
2889 if (len >=
sizeof(socket_addr.sun_path) - 1) exit(EXIT_FAILURE);
2890 socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
2892 socket_addr.sun_family = AF_UNIX;
2894 if (connect(
socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(socket_addr.sun_family) + len))
2898 if (setsockopt(
socket_fd, SOL_SOCKET, SO_NOSIGPIPE, &set_option,
sizeof(set_option)))
2904 char *
id = getenv(
"REMAKE_JOB_ID");
2905 int job_id =
id ? atoi(
id) : -1;
2906 if (send(
socket_fd, (
char *)&job_id,
sizeof(job_id), MSG_NOSIGNAL) !=
sizeof(job_id))
2910 for (string_list::const_iterator i = targets.begin(),
2911 i_end = targets.end(); i != i_end; ++i)
2913 DEBUG_open <<
"Sending target " << *i <<
"... ";
2914 std::string s =
'T' + *i;
2915 ssize_t len = s.length() + 1;
2916 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2921 for (variable_map::const_iterator i =
variables.begin(),
2922 i_end =
variables.end(); i != i_end; ++i)
2924 DEBUG_open <<
"Sending variable " << i->first <<
"... ";
2925 std::string s =
'V' + i->first;
2926 ssize_t len = s.length() + 1;
2927 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2929 for (string_list::const_iterator j = i->second.begin(),
2930 j_end = i->second.end(); j != j_end; ++j)
2932 std::string s =
'W' + *j;
2933 len = s.length() + 1;
2934 if (send(
socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2941 if (send(
socket_fd, &result, 1, MSG_NOSIGNAL) != 1)
goto error;
2942 if (recv(
socket_fd, &result, 1, 0) != 1) exit(EXIT_FAILURE);
2943 exit(result ? EXIT_SUCCESS : EXIT_FAILURE);