2843 perror(
"Failed to send targets to server");
2846 if (targets.empty()) exit(EXIT_SUCCESS);
2851 struct sockaddr_in socket_addr;
2852 socket_fd = socket(AF_INET, SOCK_STREAM, 0);
2854 socket_addr.sin_family = AF_INET;
2855 socket_addr.sin_addr.s_addr = inet_addr(
"127.0.0.1");
2857 if (connect(socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(sockaddr_in)))
2860 struct sockaddr_un socket_addr;
2862 if (len >=
sizeof(socket_addr.sun_path) - 1) exit(EXIT_FAILURE);
2863 socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
2865 socket_addr.sun_family = AF_UNIX;
2867 if (connect(socket_fd, (
struct sockaddr *)&socket_addr,
sizeof(socket_addr.sun_family) + len))
2871 if (setsockopt(socket_fd, SOL_SOCKET, SO_NOSIGPIPE, &set_option,
sizeof(set_option)))
2877 char *
id = getenv(
"REMAKE_JOB_ID");
2878 int job_id =
id ? atoi(
id) : -1;
2879 if (send(socket_fd, (
char *)&job_id,
sizeof(job_id), MSG_NOSIGNAL) !=
sizeof(job_id))
2883 for (string_list::const_iterator i = targets.begin(),
2884 i_end = targets.end(); i != i_end; ++i)
2886 DEBUG_open <<
"Sending target " << *i <<
"... ";
2887 std::string s =
'T' + *i;
2888 ssize_t len = s.length() + 1;
2889 if (send(socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2894 for (variable_map::const_iterator i =
variables.begin(),
2895 i_end =
variables.end(); i != i_end; ++i)
2897 DEBUG_open <<
"Sending variable " << i->first <<
"... ";
2898 std::string s =
'V' + i->first;
2899 ssize_t len = s.length() + 1;
2900 if (send(socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2902 for (string_list::const_iterator j = i->second.begin(),
2903 j_end = i->second.end(); j != j_end; ++j)
2905 std::string s =
'W' + *j;
2906 len = s.length() + 1;
2907 if (send(socket_fd, s.c_str(), len, MSG_NOSIGNAL) != len)
2914 if (send(socket_fd, &result, 1, MSG_NOSIGNAL) != 1)
goto error;
2915 if (recv(socket_fd, &result, 1, 0) != 1) exit(EXIT_FAILURE);
2916 exit(result ? EXIT_SUCCESS : EXIT_FAILURE);