From: Christopher Faylor Date: Mon, 1 May 2000 02:42:14 +0000 (+0000) Subject: * path.c (exit_cygpath): Wait for subprocess to exit before returning. X-Git-Tag: cygwin-1_1_1~7 X-Git-Url: https://cygwin.com/git/?a=commitdiff_plain;h=9e76799c7e0909bfbf2e24f0907a896ec1e8c1ec;p=cygwin-apps%2Fsetup.git * path.c (exit_cygpath): Wait for subprocess to exit before returning. (cygpath_pipe): Don't call exit_cygpath. Let main atexit routine do that. * pkg.c (init_pkgs): Accept root argument. Make registry key "cygwin root"-specific. * setup.c (filedel): Call exit_cygpath here so that we can be assured that cygpath subprocess has died. This allows us to delete cygpath.exe and cygwin1.dll. (optionprompt): Initialize response to -1 so that second screen of mirrors will appear. (get_pkg_stuff): Don't attempt to use HKCLU. Pass root to init_pkgs. * setup.h: Reflect init_pkgs prototype change. --- diff --git a/ChangeLog b/ChangeLog index 6db1cc9e..c453e27c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Sun Apr 30 22:37:34 2000 Christopher Faylor + + * path.c (exit_cygpath): Wait for subprocess to exit before returning. + (cygpath_pipe): Don't call exit_cygpath. Let main atexit routine do + that. + * pkg.c (init_pkgs): Accept root argument. Make registry key "cygwin + root"-specific. + * setup.c (filedel): Call exit_cygpath here so that we can be assured + that cygpath subprocess has died. This allows us to delete cygpath.exe + and cygwin1.dll. + (optionprompt): Initialize response to -1 so that second screen of + mirrors will appear. + (get_pkg_stuff): Don't attempt to use HKCLU. Pass root to init_pkgs. + * setup.h: Reflect init_pkgs prototype change. + Sat Apr 29 23:53:30 2000 Christopher Faylor * pkg.c (init_pkgs): Accept an argument to control what root registry diff --git a/path.c b/path.c index 7a6eebfe..827f5dd7 100644 --- a/path.c +++ b/path.c @@ -44,17 +44,22 @@ kill_cygpath (int sig) exit (1); } -static void +void exit_cygpath (void) { fclose (cygin); fclose (cygout); Sleep (0); - TerminateProcess (hcygpath, 0); + if (WaitForSingleObject (hcygpath, 5000) != WAIT_OBJECT_0) + { + TerminateProcess (hcygpath, 0); + WaitForSingleObject (hcygpath, 5000); + } + CloseHandle (hcygpath); } static int -cygpath_pipe () +cygpath_pipe (void) { int hpipein[2] = {-1, -1}; int hpipeout[2] = {-1, -1}; @@ -72,7 +77,6 @@ cygpath_pipe () hcygpath = (HANDLE) xcreate_process (0, hout, hin, hin, buffer); if (!hcygpath) return 0; - atexit (exit_cygpath); signal (SIGINT, kill_cygpath); _close (hpipein[1]); _close (hpipeout[0]); diff --git a/pkg.c b/pkg.c index ddbc90b2..e8a352b7 100644 --- a/pkg.c +++ b/pkg.c @@ -218,20 +218,25 @@ err: return NULL; } +#define REGWHERE "SOFTWARE\\Cygnus Solutions\\Cygwin\\Installed Components" + pkg * -init_pkgs (int use_current_user) +init_pkgs (const char *root, int use_current_user) { LONG res; DWORD what; - char empty[] = ""; + char *p, empty[] = ""; char buf[4096]; DWORD ty, sz; DWORD nc = 0; static pkg stuff[1000]; - res = RegCreateKeyEx (use_current_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, - "SOFTWARE\\Cygnus Solutions\\Cygwin\\Installed Components", - 0, empty, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkpkg, &what); + sprintf (buf, "%s\\%s", REGWHERE, root); + for (p = buf + sizeof (REGWHERE); (p = strchr (p, '\\')) != NULL; ) + *p = '/'; + + res = RegCreateKeyEx (use_current_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, buf, + 0, empty, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkpkg, &what); if (res != ERROR_SUCCESS) return NULL; diff --git a/setup.c b/setup.c index 9310dd36..620530f8 100644 --- a/setup.c +++ b/setup.c @@ -65,9 +65,12 @@ static SA installme = {NULL, 0, 0}; static void filedel (void) { - int i; + int i, j; + extern void exit_cygpath (void); + exit_cygpath (); for (i = 0; i < deleteme.count; i++) - (void) _unlink (deleteme.array[i]); + for (j = 0; _unlink (deleteme.array[i]) && j < 20; j++) + Sleep (100); sa_cleanup (&deleteme); } @@ -140,7 +143,6 @@ create_shortcut (const char *target, const char *shortcut) return SUCCEEDED (hres); } - BOOL CALLBACK output_file (HMODULE h, LPCTSTR type, LPTSTR name, LONG lparam) { @@ -433,7 +435,6 @@ recurse_dirs (SA *installme, const char *dir) return retval; } - static void setpath (const char *element) { @@ -450,7 +451,6 @@ prompt (const char *text, const char *def) { char buffer[_MAX_PATH]; - printf ((def ? "%s? [%s] " : "%s? "), text, def); fflush (stdout); fgets (buffer, sizeof (buffer), stdin); @@ -463,7 +463,7 @@ prompt (const char *text, const char *def) static int optionprompt (const char *text, SA * options) { - size_t n, response = 1; + size_t n, response = -1; char buf[5]; size_t base; @@ -986,7 +986,6 @@ downloaddir (SA *installme, const char *url) return retval; } - static HINTERNET opensession () { @@ -1083,7 +1082,6 @@ create_uninstall (const char *wd, const char *folder, const char *shellscut, return retval; } - /* Writes the startup batch file. */ static int do_start_menu (const char *root) @@ -1262,7 +1260,6 @@ getdownloadsource () return retval; } - /* Basically a mkdir -p /somedir function. */ static void mkdirp (const char *dir) @@ -1321,11 +1318,9 @@ static pkg * get_pkg_stuff (const char *root, int updating) { const char *ver, *ans; - pkg *pkgstuff = init_pkgs (0); + pkg *pkgstuff = init_pkgs (root, 0); static pkg dummy = {NULL, NULL}; - if (!pkgstuff) - pkgstuff = init_pkgs (1); /* Use HKCU */ if (!updating || !pkgstuff) return &dummy; diff --git a/setup.h b/setup.h index e3b25d30..00eadf28 100644 --- a/setup.h +++ b/setup.h @@ -23,7 +23,7 @@ typedef struct char *version; } pkg; -pkg *init_pkgs (int); +pkg *init_pkgs (const char * root, int); pkg * find_pkg (pkg *stuff, char *name); int write_pkg (pkg *pkg, char *name, char *version); int newer_pkg (pkg *pkg, char *version);