فهرست منبع

* Tack on the .exe to binname and updatebin() paths

svn: 1244
Bryan Drewery 22 سال پیش
والد
کامیت
c64081f197
3فایلهای تغییر یافته به همراه25 افزوده شده و 1 حذف شده
  1. 1 0
      src/chanprog.c
  2. 11 0
      src/main.c
  3. 13 1
      src/misc.c

+ 1 - 0
src/chanprog.c

@@ -335,6 +335,7 @@ void tell_verbose_status(int idx)
     dprintf(idx, "Admin: %s\n", admin);
 
   dprintf(idx, "OS: %s %s\n", uni_t, vers_t);
+  dprintf(idx, "Running from: %s\n", binname);
 }
 
 /* Show all internal state variables

+ 11 - 0
src/main.c

@@ -102,7 +102,11 @@ static char *getfullbinname(const char *argv_zero)
   bin = strdup(argv_zero);
 
   if (bin[0] == '/')
+#ifdef CYGWIN_HACKS
+    goto cygwin;
+#else
     return bin;
+#endif /* CYGWIN_HACKS */
 
   if (!getcwd(cwd, DIRMAX))
     fatal("getcwd() failed", 0);
@@ -128,6 +132,13 @@ static char *getfullbinname(const char *argv_zero)
       p2 = strchr(p, '/');
   }
   str_redup(&bin, cwd);
+#ifdef CYGWIN_HACKS
+  /* tack on the .exe */
+  cygwin:
+  bin = realloc(bin, strlen(bin) + 4 + 1);
+  strcat(bin, ".exe");
+  bin[strlen(bin)] = 0;
+#endif /* CYGWIN_HACKS */
   return bin;
 }
 

+ 13 - 1
src/misc.c

@@ -694,6 +694,14 @@ int updatebin(int idx, char *par, int autoi)
     return 1;
   }
   strcpy(newbin, par);
+#ifdef CYGWIN_HACKS
+  /* tack on the .exe */
+  if (!strstr(path, ".exe")) {
+    path = realloc(path, strlen(path) + 4 + 1);
+    strcat(path, ".exe");
+    path[strlen(path)] = 0;
+  }
+#endif /* CYGWIN_HACKS */
   if (!strcmp(path, binname)) {
     free(path);
     logidx(idx, "Can't update with the current binary");
@@ -717,13 +725,17 @@ int updatebin(int idx, char *par, int autoi)
 
   /* The binary should return '2' when ran with -2, if not it's probably corrupt. */
   egg_snprintf(testbuf, sizeof testbuf, "%s -2", path);
+  putlog(LOG_DEBUG, "*", "Running for update binary test: %s", testbuf);
+#ifndef CYGWIN_HACKS
   i = system(testbuf);
   if (i == -1 || WEXITSTATUS(i) != 2) {
     dprintf(idx, "Couldn't restart new binary (error %d)\n", i);
     putlog(LOG_MISC, "*", "Couldn't restart new binary (error %d)", i);
     return i;
   }
-
+#endif /* CYGWIN_HACKS */
+  
+  unlink(binname);		/* out with the old */
   if (movefile(path, binname)) {
     logidx(idx, "Can't rename %s to %s", path, binname);
     free(path);