diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-06-04 21:13:34 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-06-04 21:13:34 +0000 |
commit | 7a24bc6f9816214ea2e56dd427699d763f36599c (patch) | |
tree | 81ba41e4316e7a6097c1a34cf3f365ac69b8631a /lib/server | |
parent | 1ab89d2bcda71194a5d3465d5078e9d01bcd520f (diff) |
Hopefully reset getopt in a way that's compatible with BSD and GLIBC,
thanks to Tobias Balle-Petersen for pointing out this bug.
Diffstat (limited to 'lib/server')
-rw-r--r-- | lib/server/Daemon.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index f2728459..9ff270a9 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -110,7 +110,16 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) #endif char c; - optind = 0; // just in case anybody used getopt before + + // reset getopt, just in case anybody used it before. + // unfortunately glibc and BSD differ on this point! + // http://www.ussg.iu.edu/hypermail/linux/kernel/0305.3/0262.html + #ifdef __GLIBC__ + optind = 1; + #else + optind = 0; + optreset = 1; + #endif while((c = getopt(argc, (char * const *)argv, "c:DqvVt:Tk")) != -1) { |