- r = connect(fd, &sun, sizeof(sun));
- if (r) {
- if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
- goto cannot;
- if (errno != EINPROGRESS)
- err("connect to garbage socket (%s)", sun.sun_path);
- /* well, EINPROGRESS, let's just carry on and hope write works */
- }
-
- r = write(
-
-
-static void tidy_garbage(void) {
- const char *this_garbage =
- m_asprintf("%s/g%lu.%lu", run_base,
- (unsigned long)sock_stab.st_ino,
- (unsigned long)getpid());
-
- r = rename(socket_path, this_garbage);
- if (r) {
- if (!(errno == ENOENT))
- err("rename socket from old runner (from %s to %s)",
- socket_path, this_garbage);
- }
-
- DIR *d = opendir(run_base);
- if (!d) err("open run directory (%d) to clean up garbage", run_base);
- struct dirent *de;
- while ((errno = 0, de = readdir(d))) {
- if (de->d_name[0] != 'g')
- continue;
- tidy_1_garbage(de->d_name);
+ if (check_garbage()) {
+ r = unlink(socket_path);
+ if (r) {
+ if (!(errno == ENOENT))
+ err(127,"remove out-of-date socket (%s)", socket_path);
+ }