Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18753/ntfsprogs
Modified Files:
ntfsresize.c
Log Message:
Fix compilation on OSX in ntfsresize.c where stderr = stdout is not
legal (but happens to work on Linux) to do proper low-level file
descriptor mangling which is portable. (Anton)
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsresize.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -p -r1.97 -r1.98
--- ntfsresize.c 12 Oct 2005 11:52:41 -0000 1.97
+++ ntfsresize.c 15 Oct 2005 21:26:16 -0000 1.98
@@ -523,12 +523,20 @@ static int parse_options(int argc, char
}
}
- 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
if (ver)
|