On 8/13/12 11:56 AM, Christopher Faylor wrote: > On Mon, Aug 13, 2012 at 07:56:52PM +0200, Pawel Jasinski wrote: >> hi guys, >> >> is that what we talking about (see patch below)? > > Thanks for the patch but I wasn't looking for a simple patch to do this. > I said I'd make the change if someone could suggest a better errno. > > When I suggested a patch, it was to somehow change the way Cygwin > reported errors so that Windows errors could be exposed to programs that > aren't expecting them. I was willing to look at an implementation if > someone was going to take the time to add the non-trivial amount of code > this would take.
I like the way the Windows CRT solves this problem. It provides a traditional errno with the traditionally restricted set of error codes, but also provides something called "_doserrno" that holds the OS-level error code that generated the last errno. If Cygwin were to provide a similar facility, Someone could patch high-visibility programs like bash so that they'd display the Windows-level information instead of the familiar strerror(errno) message. Granted, not all errno-errors come from Win32 errors, so to avoid confusion, you'd want to set _doserrno to zero every time you set errno, then (in select places inside Cygwin) set _doserrno. Looking at the bash code, I think the change there would involve mechanically replacing all the uses of strerror (errno) with some xstrerror (errno, _doserrno), and having xstrerror do the right thing.
signature.asc
Description: OpenPGP digital signature