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.
This commit is contained in:
antona 2005-10-15 21:48:37 +00:00
parent f5961c075e
commit da1495a11d
2 changed files with 14 additions and 7 deletions

View File

@ -12,9 +12,9 @@ xx/xx/2005 - 1.12.2-WIP
- Fix silly bug introduced in 1.12.0 which breaks ntfsfix (and others
possibly) when calling ntfs_attr_lookup() with AT_UNNAMED name and
no ntfs inode in the search context. (Anton)
- Fix compilation on OSX in ntfsresize.c and ntfsclone.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)
- Fix compilation on OSX in ntfsresize.c, ntfsclone.c, and ntfscmp.c
where stderr = stdout is not legal (but happens to work on Linux) to
do portable low-level file descriptor mangling. (Anton)
- Add test/runlist-data to EXTRA_DIST so it gets included in the
distribution otherwise make test fails on released sources. Solution
is not perfect as it also adds the test/runlist-data/CVS directory

View File

@ -224,13 +224,20 @@ static void parse_options(int argc, char **argv)
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
}