]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* path.c (kill_cygpath): Delete function.
authorChristopher Faylor <me@cgf.cx>
Tue, 2 May 2000 02:12:35 +0000 (02:12 +0000)
committerChristopher Faylor <me@cgf.cx>
Tue, 2 May 2000 02:12:35 +0000 (02:12 +0000)
(exit_cygpath): Make more defensive so that it can be called at any time.
(cygpath_pipe): Don't set up signal here.  Do it in main().
* setup.c (istargz): New function.
(recurse_dirs): Look for *.gz pattern rather than *tar.gz since *tar.gz
inexplicably fails on samba mounted partitions.  Use istargz to match tar.gz
tail.
(processdirlisting) Use istargz to match tar.gz tail.
(cleanup): Renamed from filedel.
(cleanup_on_signal): New function.  Called on CTRL-C.
(main): Record handle of main thread so that it can be suspended when CTRL-C
occurs.  Set up cleanup_on_signal signal handler.

ChangeLog
path.c
setup.c

index e797e38a94255b9e0453ee1a635e6d963e6f142d..2163d0d8ff169f48b5e0902b66c75a495047819d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Mon May  1 17:56:32 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * path.c (kill_cygpath): Delete function.
+       (exit_cygpath): Make more defensive so that it can be called at any
+       time.
+       (cygpath_pipe): Don't set up signal here.  Do it in main().
+       * setup.c (istargz): New function.
+       (recurse_dirs): Look for *.gz pattern rather than *tar.gz since *tar.gz
+       inexplicably fails on samba mounted partitions.  Use istargz to match
+       tar.gz tail.
+       (processdirlisting) Use istargz to match tar.gz tail.
+       (cleanup): Renamed from filedel.
+       (cleanup_on_signal): New function.  Called on CTRL-C.
+       (main): Record handle of main thread so that it can be suspended when
+       CTRL-C occurs.  Set up cleanup_on_signal signal handler.
+
 Mon May  1 11:05:07 2000  Christopher Faylor <cgf@cygnus.com>
 
        * setup.c (do_start_menu): Don't concatenate paths to already built
diff --git a/path.c b/path.c
index 827f5dd74b5a6452b8ed6d54e838f028c3cde2c1..d53c139f5514c61bfd3af738d7adc5c9fa611b44 100644 (file)
--- a/path.c
+++ b/path.c
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <signal.h>
 
 #include "setup.h"
 #include "strarry.h"
 #include "zlib/zlib.h"
 
-static FILE *cygin, *cygout;
-static HANDLE hcygpath;
-
-static void
-kill_cygpath (int sig)
-{
-  TerminateProcess (hcygpath, 0);
-  exit (1);
-}
+static FILE *cygin = NULL, *cygout = NULL;
+static HANDLE hcygpath = NULL;
 
 void
 exit_cygpath (void)
 {
-  fclose (cygin);
-  fclose (cygout);
-  Sleep (0);
-  if (WaitForSingleObject (hcygpath, 5000) != WAIT_OBJECT_0)
+  if (cygin)
+    fclose (cygin);
+  if (cygout)
+    fclose (cygout);
+  if (hcygpath)
     {
-      TerminateProcess (hcygpath, 0);
-      WaitForSingleObject (hcygpath, 5000);
+      Sleep (0);
+      if (WaitForSingleObject (hcygpath, 5000) != WAIT_OBJECT_0)
+       {
+         TerminateProcess (hcygpath, 0);
+         WaitForSingleObject (hcygpath, 5000);
+       }
+      CloseHandle (hcygpath);
     }
-  CloseHandle (hcygpath);
 }
 
 static int
@@ -77,7 +74,6 @@ cygpath_pipe (void)
   hcygpath = (HANDLE) xcreate_process (0, hout, hin, hin, buffer);
   if (!hcygpath)
     return 0;
-  signal (SIGINT, kill_cygpath);
   _close (hpipein[1]);
   _close (hpipeout[0]);
   cygin = fdopen (hpipein[0], "rt");
diff --git a/setup.c b/setup.c
index 9150749f505878ec14fc8ad692c7849a913a9389..19c12f483504767884a3f2a58d0e7b3577622070 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -29,6 +29,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdarg.h>
+#include <signal.h>
+#include <process.h>
 
 #include "setup.h"
 #include "strarry.h"
@@ -61,9 +63,10 @@ static SA deleteme = {NULL, 0, 0};
 static pkg *pkgstuff;
 static int updating = 0;
 static SA installme = {NULL, 0, 0};
+static HANDLE hMainThread;
 
 static void
-filedel (void)
+cleanup (void)
 {
   int i, j;
   extern void exit_cygpath (void);
@@ -74,6 +77,29 @@ filedel (void)
   sa_cleanup (&deleteme);
 }
 
+static void
+cleanup_on_signal (int sig)
+{
+  /* I have no idea why this is necessary but without this code
+     seems to continue executing in the main thread even after
+     the ExitProcess. */
+  SuspendThread (hMainThread);
+  _cexit ();
+  ExitProcess (1);
+}
+
+static int
+istargz (char *fn)
+{
+  int len = strlen (fn);
+
+  if (len > sizeof (".tar.gz") &&
+      stricmp (fn + len - (sizeof ("tar.gz") - 1), "tar.gz") == 0)
+    return 1;
+
+  return 0;
+}
+
 void
 warning (const char *fmt, ...)
 {
@@ -396,7 +422,7 @@ recurse_dirs (SA *installme, const char *dir)
          if (!err)
            {
              xfree (pattern);
-             pattern = pathcat (dir, "*tar.gz");
+             pattern = pathcat (dir, "*.gz");
              handle = FindFirstFile (pattern, &find_data);
              if (handle != INVALID_HANDLE_VALUE)
                {
@@ -405,9 +431,10 @@ recurse_dirs (SA *installme, const char *dir)
                  do
                    {
                      /* Skip source archives and meta-directories */
-                     if (strstr (find_data.cFileName, "-src")
+                     if (strstr (find_data.cFileName, "-src") != 0
                          || strcmp (find_data.cFileName, ".") == 0
                          || strcmp (find_data.cFileName, "..") == 0
+                         || !istargz (find_data.cFileName)
                          || !filematches (installme, find_data.cFileName))
                        {
                          continue;
@@ -844,7 +871,7 @@ processdirlisting (SA *installme, const char *urlbase, const char *file)
          if (refmatches (installme, ref, refend))
            retval += downloaddir (installme, url);
        }
-      else if (strstr (url, ".tar.gz") && !strstr (url, "-src"))
+      else if (istargz (url) && !strstr (url, "-src"))
        {
          int download = 0;
          char *filename = strrchr (url, '/') + 1;
@@ -856,7 +883,7 @@ processdirlisting (SA *installme, const char *urlbase, const char *file)
 
          retval++;
 
-         if (stricmp (filename, "cygwin-20000301.tar.gz") == 0)
+         if (strnicmp (filename, "cygwin-20000301", sizeof ("cygwin-20000301") - 1) == 0)
            normalize_version ("cygwin-1.1.0.tar.gz", &pkgname, &pkgversion);
          else
            normalize_version (filename, &pkgname, &pkgversion);
@@ -1402,7 +1429,11 @@ those as the basis for your installation.\n\n"
 
   start = clock ();
   sa_init (&deleteme);
-  atexit (filedel);
+  DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
+                  GetCurrentProcess (), &hMainThread, 0, 0,
+                  DUPLICATE_SAME_ACCESS);
+  atexit (cleanup);
+  signal (SIGINT, cleanup_on_signal);
 
   if (!EnumResourceNames (NULL, "FILE", output_file, 0))
     {
This page took 0.034571 seconds and 5 git commands to generate.