Friday, July 20, 2007

Cygwin X Server under Windows Vista

The adventure that is figuring out how to do everything I do on my old ThinkPad T30 laptop under Windows XP on my new ThinkPad X61 tablet under Windows Vista continues. The latest was how to start up the Cygwin X server to I can hack my Linux servers from the new laptop.

Several other folks have reported the issues with the Cygwin fork() call under Vista in various contexts, including when running the Cygwin shell script startx. I don't have a fix for that. Instead I poked around my XP laptop and discovered that I had created a shortcut named startx that in fact ran the batch script /usr/X11R6/bin/startxwin.bat. So in short, I've never been using the stock Cygwin startx script under XP ever since I installed Cygwin on my old T30 four years ago. I have absolutely no memory of what troubleshooting I may have done back then to arrive at this solution. But it works under Vista too.

I diffed my XP batch script and the latest Cygwin batch script I downloaded and installed on Vista just a couple of days ago. The only differences are local changes: I commented out the xterm and added an xhost + just to make my life easier behind the Digital Aggregates firewall.

I am now happily using X windows from my Linux systems on my Vista tablet. As always, your mileage may vary, as testing continues.

Update (2007-12-23)

This is currently the most popular single article I've ever written for this blog, which tells you something about the pain people are going through to be productive using Vista. If you've read the comments, you know that Cygwin X server on Vista has broken for me at least once, I'm guessing due to Vista updates. What broke it, I have no fracking clue. The X server started up under Vista just fine, I could run X applications like xterm from my Linux systems or even from Cygwin on my Vista system itself, but no windows appeared on my Vista screen.

After some troubleshooting, I ended up going to C:\cygwin\usr\X11R6\bin (your mileage may vary depending on where you chose to install Cygwin), right-clicking on XWin.exe and going to Properties, selecting the Compatibility tab, and enabling Run this program in compatibility mode for Windows XP (Service Pack 2). Selecting run as Administrator not only didn't fix the problem, it kept X server from coming up at all (I got a Vista error popup).

You can be sure when my evil plans for world conquest come to fruition, things are going to be run differently.

Update (2008-02-16)

After living with my current setup for a couple of months since my last update, I find that this solution does not work reliably either. Sometimes I can get it to work again by bringing up the Task Manager, ending XWin.exe, and restarting it. Sometimes not. I tried executing the commonly cited tip of bringing up a Windows cmd window, cd C:\cygwin\bin and ash -c rebaseall (which apparently fixes some DLL address space collision issues that cause the problem with cygwin fork that originally plagued me), but to no avail.

Instead I've chucked the whole thing and have installed Xming, a native port of X to Windows that does not rely on cygwin at all. I'll let you know how it goes.

Update (2010-12-08)

Over the past couple of years I've chucked almost the whole Windows thing. I replaced Windows Vista with Windows 7 on my ThinkPad X61, replaced my daily use of that same laptop with a MacBook Air, and replaced my old IBM ThinkPad T30 running Windows XP that I had used mostly as an X window server to my Linux systems with a Mac Mini with a 27" Cinema display. I still use the X61 from time to time to run a small amount of Windows-centric software I need to run my company. But all my daily work is now all Macs with a couple of Linux servers underneath.

9 comments:

Anonymous said...

Hi:
Google brought me here. I have both the X61 and X61T, and need to run cygwin X.

I edited the startxwin batch file as you suggested. When I run the script, I do get the X icon in the tray, but still get the fork() errors when calling xterm& from the main cygwin window.

Can you email the modified script?
(d dot brady at neu dot edu). Any other advise to get X to run is greatly appreciated.

Unknown said...

Hey,

I don't know if you have already tried this, but right click the X.bat in the cygwin directory and say "run as administrator". Before I did that the X window would never run, and after I did that the x window opened up. Hope this helps.

Chip Overclock said...

It's been long enough, I can't remember if I tried that or not. I do recall having to enable "run as administrator", but it may not have been on X.bat. Thanks for the tip!

Chip Overclock said...

This AM I tried firing up the Cygwin X server on my Vista laptop, and now it fails to come up. It worked fine some time ago, but I confess I've been doing most of my Linux hacking from my T30 XP laptop in its docking station, because it has the big flat panel LCD display, wireless mouse, etc.

So some Vista update has broken my Cygwin X server on Vista.

Chip Overclock said...

My mistake: Cygwin X server didn't come up because it was already running (it gets started when I boot my laptop). I thought it wasn't running (and it's icon was hidden on the toolbar) because xterms etc. on my Linux systems weren't coming up. So I have a problem, it's just not the problem I thought I had.

Chip Overclock said...

Okay, so I've got it working again.

I went to C:\cygwin\usr\X11R6\bin, right clicked on XWin.exe and selected properties, then set the binary executable to run in Windows XP compatibility mode.

Setting it to run as Administrator, as has been suggested, did NOT work. In fact, much to my surprise, it wouldn't even start (got a popup error window from Vista).

No fracking clue what changed to break this in Vista.

Anonymous said...

I was just about thinking really to leave vista and windows for good, since after all I can have most of it - and specially must better X tools - under linux... but a miracle Happenned. I just had installed some fresh version of cygwin, hoping that it was running unde vista, but it was not. Saying "you must intall cygwin1.dll" and others. I played for hours to try to run directly from usr/X11R6/bin various .exe or .bat, and finally it worked. To activate it I simply run "cygwin bash shell" in the gygwin section of the programs in the start menu, and the type StartX in the windows that pops up. Then a X window will be opened when needed....up to the next update ?

Unknown said...

I have the same problem and rebaseall works fine.

Here's how:

First, in cygwin, type:
$which rebaseall

Find the path that you installed rebaseall, mine is /usr/bin/

Second, quit cygwin and Start/Run/Cmd, goto you cygwin install path cygwin/bin/

Third, type:
ash -c /usr/bin/rebaseall

wait sometime.

Finally, open cygwin and startx.

Works like a charm for me.

Chip Overclock said...

Indeed, that was exactly my experience as well. For a while. Until, I suspect, I accepted some batch of Vista updates thrown at me by Microsoft. Then it broke. I went through this cycle several times before I decided the time investment on my part demanded a Plan B. I still use the Cygwin X server on my XP ThinkPad, but have not regretted moving to Xming on my Vista ThinkPad.