On Thursday, March 31, 2005 7:10 PM, Alexander Gottwald wrote: >On Thu, 31 Mar 2005, Armbrust, Daniel C. wrote: > >> Because I execute the entire script twice, since the first >> execution doesn't bring up any xterms. >> >> Still not sure what is causing it to take so long to launch the >> xwin.exe. >> >> Can I set the timeout values on the xterm's with a flag? > > no. Use sleep to delay starting the xterms
When I first started using Cygwin/X, I found that XWin.exe returns before it is really ready for business. This means that commands in startxwin.bat/whatever, such as xhost or xmodmap, try to communicate with the server while it is still initialising. To get around this, I added the following kludge to my startxwin.bat. It is essentially the same as the sleep solution, except that it only sleeps for as long as is necessary. If X is started by Windows startup, all manner of delays may mean that the sleep time that works 90% of the time will be too short 10% of the time. It works by waiting for the line to appear in the log file that announces its success. This hack has to go *immediately* after XWin.exe is started. You'll probably find that the line to set LASTLINE has become wrapped. Everything from SET to the second " is a single line. People using startx will need a similar solution, but will be able to use more elegant code instead of the unholy mess that CMD.EXE forced me to write! ---8<-------------------------------------------------------- set XWIN_LOG=%CYGWIN_TMP%\XWin.log set LASTLINE="XOpenDisplay () returned and successfully opened the display." set /a COUNT=0 :WAITFORLOG echo ...Waiting for X log file... sleep 1 set /a COUNT+=1 if not exist %XWIN_LOG% goto WAITFORLOG if %COUNT% GEQ 10 goto WARNFINISHOFF set /a COUNT=0 :WAITFORIT echo ...Waiting for X to complete initialisation... sleep 1 set /a COUNT+=1 if %COUNT% GEQ 30 goto WARNFINISHOFF %SYSTEMROOT%\system32\find.exe %LASTLINE% < %XWIN_LOG% > nul if errorlevel 1 goto WAITFORIT echo "X started OK" goto FINISHOFF :WARNFINISHOFF echo "WARNING: X doesn't appear to have started cleanly" sleep 5 :FINISHOFF --8<------------------------------------------------------- Not pretty, but it WFM. Note1: %CYGWIN_TMP% is the location of cygwin's /tmp as returned by the command "cygpath -d /tmp". Note2: The actual value used for LASTLINE should be taken from your own XWin.log following a successful start. As its name suggests, it's the last line from the file. (I.e. AFTER XWin.exe has really finished, but BEFORE any clients have been started) Note3: it uses windows' find.exe rather than cygwin's grep, because grep isn't (or wasn't) part of a minimal installation. Note4: if you hack startxwin.bat, save it under a different name e.g. mystartx.bat otherwise, the next time you update X, you'll lose your changes (you may detect the voice of bitter experience here ;-) Note5: There are too many notes for such a short bit of code! Of course, the *real* solution is for XWin to return only when it has completed ALL of its initialisation. My home PCs are now certified 100% Microsoft free :-), and there is no chance of me getting time to look at this at work, so unless someone else is prepared to do it, the above will have to suffice. Anyway, the above WFM, it may help solve some of the other problems people have been having with start-up. HTH, Phil -- ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************