Cygwin

Where would I be without Cygwin? The answer to that is "not using Windows".

The only thing better than Cygwin is a true Linux box, which admitadly is where I spend a lot more of my time these days.

This page contains patches, scripts, comments and observations that may be helpful regarding Cygwin that I've put together.

At the time of creating this page, without a Linux machine, Cygwin got most of my attention. Now with a Linux machine, while I still use it both at work and home a lot, I play with it less, hence this page is now updates less frequently.

Some of this may, obviously, also be applicable in Linux or other UN*X's.

Patched Software

The following are packages I've patched and/or built under cygwin.

Please note a few things.

  • These are listed FYI. If they don't work, you're on your own.
  • Cygwin is required. It's avaliable at www.cygwin.com. No cygwin binaries are stored on this site.
  • ONLY cygwin patches are stored here. The original sources are also required and not found on this site.
  • I install all non net release applications under /usr/local, NOT /usr. The patches are set up in this way.

	Extract source to /tmp
	Extract patch to files /tmp/<package>/CYGWIN-PATCH
	% cd /tmp/<package>
	% patch -p1 < CYGWIN-PATCHES
	% CYGWIN-PATCHES/build.sh $version $build # (or read CYGWIN-PATCHES/README)
					

casu-3.3.3

I studied at RMIT, what can I say? [smile] to sends a message to a user's terminal, and flon lists 'friends' that are logged on.
Patched:
Configure.in, Makefile.in
Simple patch to fix cygwin problem with 'install/INSTALL' when '.' is in $PATH, and make to create non existant install directories, rather than assuming they exist (since the /usr/local hirachy doesn't by default in cygwin).
Added:
CYGWIN-PATCHES/build.sh
CYGWIN-PATCHES/casu.patch
CYGWIN-PATCHES/README
Build Notes:
Built with cygwin-1.3.22, cygwin-1.5.5
Building is simple - apply the patch, and run build.sh. Or take a look at README and build.sh to make manually. There's very little to go wrong.
Cygwin Notes:
Both to and flon run fine under cygwin. Sometimes flon reports users logged on when they're not - but so does who and w - it's a cygwin utmp thing.

elm-2.5.6

elm is dead, and has been for a while, but it always had some cool utils. elm was patched specifically to use newmail with cygwin. Whole package builds, utilities run fine. Elm itself sends mail, but generally dies on reading mailboxes. Although it'd be sweet to have elm working for historical purposes, I haven't bothered with getting elm itself working correctly - I'm too used to mutt these days anyway. newmail, wnewmail, fastmail and frm all seem to work well at the very least.
Patched:
Make.defs.SH, utils/Makefile.SH, src/Makefile.SH
Added:
CYGWIN-PATCHES/build.sh
CYGWIN-PATCHES/casu.patch
CYGWIN-PATCHES/README
Build Notes:
Built with cygwin-1.3.22, cygwin-1.5.5
Cygwin Notes:
Requires /usr/local/lib, /usr/local/man/cat1, /usr/local/man/mann, but from memory make makes them.

newmail notes:
  • newmail does kill itself when the shell exits, under cygwin. It's written only to check it's parent's pid every interval, so because of how cygwin works, remote shells (ssh, telnet, etc.) will appear to hang (since they don't exit while there is still backgrounded processes running on the tty) for at most interval seconds. It will then correctly exit, and then connection will close. Although newmail could be patched to handle this cygwin quirk easily enough, use pkill -t `tty` ^newmail|NEWMAIL$ in your shell's logout script if you want it to die immediately at logout.
  • Redirecting stderr (to supress the interval warning message) causes problems (newmail dies). wnewmail doesn't suffer this problem. My best guess is that it's a cygwin quirk - newmail backgrounding itself then having stderr redirected must make isatty(1) fail. (Having the shell background wnewmail while redirection stderr seems to work).

screen-3.9.10

This is actually patched by Antonio Dellelce. I take no credit for it, it's just listed here because I've built and use screen on cygwin.
http://dellelce.com/code/screen/
Cygwin Notes:
Antonio's page gives a good description of what doesn't work and anything else you need to know about the cygwin patch.

screen-3.9.15

I'm not the first to patch screen (see http://dellelce.com/code/screen/ for a pre-compiled binary of screen-3.9.10), I'm sure I won't be the last.
In anycase, my patch of screeen 3.9.15 disables detaching (re-attaching doesn't work in cygwin), which prevents accidental usage of the destructive ^A ^d keystroke.
Patched:
configure.h.in, misc.c, pty.c, utmp.c
Patched .c files simple guard code with __CYGWIN__ to suit cygwin (hence, patched code should compile on other systems). configure.h.in removes DETACH define, adds #ifdef DETACH to some other defines (which code checks, rather than checking DETACH - thus they shouldn't be defined if DETACH isn't).
Added:
CYGWIN-PATCHES/build.sh
CYGWIN-PATCHES/screen.patch
CYGWIN-PATCHES/screen.detach.patch
CYGWIN-PATCHES/README
Build Notes:
Built with cygwin-1.3.22, cygwin-1.5.5
To re-enable detaching, first apply screen.patch, then screen.detach.patch. CYGWIN-PATCHES/README has more detailed instructions.
To enable debugging, you have to set OPTIONS=DEBUG in Makefile.in, then configure and make. (Since I'm not sure how to do this with configure).
Cygwin Notes:
In case you missed it, screens can not be re-attached in cygwin
Although this patch prevents accidental detaching with ^A ^d, ^A ^z (suspend) still works, leaving you with detached screens you can't get back to.

Scripts

killp.csh

killp is a pkill wrapper - simply makes killing processes by name easier in cygwin. It takes two things into account:
  • Process names in cygwin sometimes vary in case, while pkill is case sensative.
    This is most likely a FAT vs. NTFS issue - while most process names under Win9x come up as uppercase (and sometimes lowercase), process names under XP (and maybe all NT's) come up as lowercase, as far as I know. The script users a case insensative regex, that will kill both upper and lower case process names.
  • This is not a cygwin issue, but by design pkill uses a regex pattern for killing processes - as cool as this is, it's annoying when you issue pkill ssh and having your sshd processes killed as well. killp.src passes the -x (match exactly) switch to pkill, so that it only kills process names that match exactly.
killp.csh supports all pkill switches (-P <ppid>, -p <pgrp>, -s <sid>, -u <euid>, -U <uid>, -G <gid>, -t <term>, -n) except -x (implied).

Random Comments

Tuesday, July , 2003 - Fixed $TERM issues

Fixed term issues I've been having under rxvt (native windows).
  • Firstly 'rxvt' works nicer than the default 'xterm'.
  • Use ~/.Xdefaults 'rxvt*termName: rxvt'.
  • Mutt issue was with /etc/muttrc. Issue with mutt coming up all blank in rxvt (black on white) is with the colors used by mutt. Use 'color normal normal', in rc file which works with black on white, and white on black (dos box).

Monday, September , 2003 - remote connection from screen / dumb terminal

Have reinstalled screen and noticed that a remote terminal (ssh, telnet) doesn't play nicely with the 'screen' term type (even with screen installed / functioning correctly on the remote machine locally). I guess this has to do with the termcap (?) info environment set under screen, which isn't inherited by the remote shell. Since this 'environment' variable doesn't have a name, I don't know how to set it manually. But doing so may fix it. For the time being, use alias less to 'less -d' to make less less (no pun intended) annoying in a shell on a remote machine.

Saturday, September , 2003 - shutdown patch for win9x

Have submitted my patch for shutdown-1.3-1 to correctly shutdown (instead of logoff) with -s under Win9x.

Sunday, September , 2003 - shutdown patch for win9x in net release

Patch for shutdown included in shutdown-1.4-1 release.

Saturday, September , 2003 - cygwin-1.5.4 breaks fetchmail

Updating to 1.5.4 (to use shutdown-1.4) seems to break fetchmail on Win9x, in that it fails to remove stale lock files. On having a look at the code, it seems unlink() in 1.5.4 is broken on Win9x - have taken it to the cygwin mailing list.

Tuesday, September , 2003 - pgrep/pkill 01801-2 broken

pkill/pgrep (procps-010801-2) binaries seems to be broken, in regards to -t <tty>.
9:08pm [ord@scholars ~] > /usr/bin/pgrep -t tty1
9:08pm [ord@scholars ~] >
Rebuilding it from the source seems to work though. Weird...
9:08pm [ord@scholars ~] > /usr/local/bin/pgrep -t tty1
610175
784355
9:08pm [ord@scholars ~] >

Saturday, October , 2003 - cygwin-1.5.4 breaks fetchmail - fix

After some discussion on the cygwin mailing list, my assumption on my unlink() wasn't working on Win9x was correct. Apparently it's now fixed in cvs - if only my internet connection wasn't sucking this weekend... [smile]

Saturday, October , 2003 - run daemons as 'daemon'

I thought 1) cygwin didn't have su and then 2) didn't have it but worked. I tried it today, and it actually seems to work. Hence, it's nice to run /etc/rc as 'daemon', such that pkill -9 -u <user> doesn't kill daemon processes (and conversly pkill -9 -u daemon only kills processes owned by daemon). It's achieved with a shortcut:
C:\cygwin\bin\su.exe -m -f -c "exec /sbin/init.exe -i INT" daemon
  • -m preserves the environment. Otherwise sshd (hence ssh sessions) won't get things like $WINDIR, which some of my scripts depend on.
  • -f skips the shell startup files for daemon, which contain environment variables I don't want ssh sessions to see.
  • -c makes su run init.
  • exec is supposed to make /sbin/init run in place of /bin/su (to conserve some resources), though it doesn't seem to work (su remains running).
The only side effect I see is that sshd (running from inetd) runs as daemon, rather than $USER, which is kinda a cool thing anyway (in terms of kill anyway).

Oh, and the 2 extra processes that run as a result (su and tcsh) as opposed to running /sbin/init directly. (On a Celeron 333MHz with 64MB RAM, I'm concious of such things. [wink]

Sunday, May , 2004 - W3C HTML Validator SGML Parser + cygwin

Switch Styles

About Style Switching.