This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: cygpath hangs from postinstall scripts when called like $(cygpath -S) but not otherwise


> From: Igor Pechtchanski
> Sent: Monday, October 06, 2003 4:40 PM

> On Mon, 6 Oct 2003, Hannu E K Nevalainen wrote:
>
> > > From: Igor Pechtchanski
> > > Sent: Monday, October 06, 2003 1:44 AM
> >
> > > It would be easy to check if the above was the reason for the hang by
> > > trying to call the following program from a postinstall
> script and seeing
> > > if it also hangs:
> >
> > It doesn't hang. :-I
>
> Well, so much for that idea...

 Yup. :-7

> 	Igor

I had another idea; look up the postinstall launch code in setup
(script.cc/run), copy it and try to create a "testcase".

This seems to be futile though, at least I've had no luck.

I've got one idea left: recompile setup 2.415-1 by myself and try that. I'll
see how fast that gets done. I'm tired right now.
I've cvs'ed sources as:
 cvs -z3 -d :pserver:anoncvs@sources.redhat.com:/cvs/cygwin-apps co setup
I assume this is the last available. That cvs invocation worked right out of
the box, it's real nice when it is like that.


Nevertheless I'm sending the code onto the list so that perhaps somebody can
either use them for something worthwhile, or hopefully get an idea that
helps.

Therefore, please *do* check them. A warning though: this is my first
attempt at windows-related stuff. It is mostly copied code from elsewhere
though and not very polished (of me) as such.


I created t3.cc as *.cc as the related source in setup (script.cc) is c++.
Though I removed all dependencies in an attempt to make it self contained,
which had the side effect of making it compile as *.c too.
It doesn't seem to make any difference whether *.cc/g++ or *.c/gcc is used
as extension/compiler.
 I didn't succeed in having "\\bin\\sh.exe" as "sh" parameter to the sprintf
call (changing the cygwin root accordingly); the result wouldn't launch the
script. This might be one source of "malfunction" for the intended purpose.

 Judging from this and the fact that strace (w som exceptions) hides the
problem, I'd say that something "goes wrong" inside setup just before the
script gets launched. This "wrong" affects only cygpath as it seems - given
very specific conditions. One of these conditions is that setup must have
been started from Windows (i.e. not bash, at least).

/Hannu E K Nevalainen, B.Sc. EE - 59?16.37'N, 17?12.60'E
-- UTC+01, DST -> UTC+02  --


Intended method of use:
Put t3.sh in the cygwin root, then change the cygwin root literal in t3.cc
if it doesn't match your actual root. compile using m.sh and run t3.exe
after that.

------------
 -- m.sh --
------------
#!/bin/bash -x
g++ -o t3 -mno-cygwin t3.cc


-------------
 -- t3.sh --
-------------
#!/bin/bash -x

TOPFOLDER="`cygpath -A -P`/Cygwin-XFree86"
echo $TOPFOLDER

echo "Hit ENTER"
read cr

-------------
 -- t3.cc --
-------------
#include <windows.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <process.h>

int WINAPI
WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR xcmdline, int nShow) {

  char cmdline[_MAX_PATH];
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  DWORD flags = CREATE_NEW_CONSOLE;
  BOOL inheritHandles = FALSE;

//                              sh,       args, file
  sprintf (cmdline, "%s %s %s", "sh.exe", "-c", "/t3.sh");
  memset (&pi, 0, sizeof (pi));
  memset (&si, 0, sizeof (si));
  si.cb = sizeof (si);
  si.lpTitle = (char *) "Cygwin Setup Post-Install Script";
  si.dwFlags = STARTF_USEPOSITION;

#if 0
  if (file_out.isValid ())
    {
      inheritHandles = TRUE;
      si.dwFlags |= STARTF_USESTDHANDLES;
      si.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
      si.hStdOutput = file_out.handle ();
      si.hStdError = file_out.handle ();
      si.dwFlags |= STARTF_USESHOWWINDOW;
      si.wShowWindow = SW_HIDE;
      flags = CREATE_NO_WINDOW;  // Note: this is ignored on Win9x
    }
#endif

  BOOL createSucceeded = CreateProcess (0, cmdline, 0, 0, inheritHandles,
                                        flags, 0,
                                        "C:\\Cygwin\\bin\\",
                                        // get_root_dir ().cstr_oneuse(),
                                        &si, &pi);

	printf("createSucceeded=%d -> %s\n",createSucceeded,
(createSucceeded)?"started.":"failed to start.");

  if (createSucceeded)
    WaitForSingleObject (pi.hProcess, INFINITE);
  CloseHandle(pi.hProcess);
  CloseHandle(pi.hThread);

	printf("Leaving WinMain\n");
}

--END OF MESSAGE--


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]