Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22454/ntfsprogs
Modified Files:
ntfscmp.c
Log Message:
Fix compilation on OSX in ntfscmp.c where stderr = stdout is not legal (but
happens to work on Linux) to do portable low-level file descriptor mangling.
Index: ntfscmp.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscmp.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -r1.9 -r1.10
--- ntfscmp.c 12 Oct 2005 11:52:41 -0000 1.9
+++ ntfscmp.c 15 Oct 2005 21:48:37 -0000 1.10
@@ -224,13 +224,20 @@ static void parse_options(int argc, char
usage();
}
- stderr = stdout;
+ /* Redirect stderr to stdout, note fflush()es are essential! */
+ fflush(stdout);
+ fflush(stderr);
+ if (dup2(STDOUT_FILENO, STDERR_FILENO) == -1) {
+ perror("Failed to redirect stderr to stdout");
+ exit(1);
+ }
+ fflush(stdout);
+ fflush(stderr);
#ifdef DEBUG
if (!opt.debug)
- if (!(stderr = fopen("/dev/null", "rw")))
- perr_exit("Couldn't open /dev/null");
-
+ if (!freopen("/dev/null", "w", stderr))
+ perr_exit("Failed to redirect stderr to /dev/null");
#endif
}
|