+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
#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
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");
#include <sys/types.h>
#include <sys/stat.h>
#include <stdarg.h>
+#include <signal.h>
+#include <process.h>
#include "setup.h"
#include "strarry.h"
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);
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, ...)
{
if (!err)
{
xfree (pattern);
- pattern = pathcat (dir, "*tar.gz");
+ pattern = pathcat (dir, "*.gz");
handle = FindFirstFile (pattern, &find_data);
if (handle != INVALID_HANDLE_VALUE)
{
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;
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;
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);
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))
{