|
Subject: Re: Re: I/O problem solvable.... need Help though. Newsgroups: gmane.comp.lib.sdl Date: 2005-01-22 19:28:15 GMT (4 years, 23 weeks, 3 days, 2 hours and 35 minutes ago) Benjamin Deutsch <ben <at> fictiongroup.de> wrote: > I see two problems with this (we might as well discuss this now, > instead of at patching time): > > 1) Most apps on Windows need this feature, since Windows has no > easily accessible standard IO otherwise. Therefore, it makes sense > to have redirection enabled by default. This reasoning is wrong for many reasons. - The linker settings one would intuitively use under MinGW give a program that will spawn a console if needed, and *also* redirect stdio. There exists no combination of linker settings such that it spawns a console and doesn't redirect stdio. - Win32 apps which are launched from a command prompt have accessible stdio, even if they don't spawn their own console when executed elsewhere. In other words, the accessibility of stdio is exactly the same as on Linux, where SDL never redirects. - stdio redirection is a portability problem; it affects only Windows, and only on some compilers/compiler settings, so it's likely to turn up as an unpleasant surprise. - The stdout.txt and stderr.txt the program produces are added to the current working directory, rather than the directory the executable is in. In addition to filesystem clutter, this means that programs with stdio redirection can't run setuid or setgid (yes, you can do that under Windows) because that would allow you to create files in, say, /Cygwin/etc/profile.d and leave trojans for other users. - stdout.txt and stderr.txt may be created even if nothing is written into them, needlessly cluttering the filesystem. > 2) Backwards compatibility. An unchanged app from before the patch > should behave the same. > > The best solution that I can see, given the two assumptions above, > is to add a function SDL_RedirectStdIO(int flag), which can be > used to turn the redirection on or off, and have it *on* by > default. > > While we're at it, let's add another state (on, off, auto), where > 'auto' behaves like originally (i.e. platform dependant), and 'on' > and 'off' force redirection on or off regardless of platform. This > way the call actually "adds value" |
|
|