diff options
author | Bruno Haible <bruno@clisp.org> | 2019-01-03 20:36:35 +0100 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2019-01-03 22:08:56 -0800 |
commit | b09adbffd5ab987f10f79a69f28b5b26eae95f3c (patch) | |
tree | 4f8e50228a51905f616e5581d68043a9c836b29b /src | |
parent | 197d7d492f1fd38e7b090f0898dfc286e518f2b7 (diff) | |
download | diffutils-b09adbffd5ab987f10f79a69f28b5b26eae95f3c.tar.gz |
diff: recognize file descriptors closed by the parent process on HP-UX
* src/diff.c (compare_files): Use fcntl to distinguish a file
descriptor closed by the parent process from a file descriptor
that references /dev/null.
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1172,6 +1172,13 @@ compare_files (struct comparison const *parent, cmp.file[f].desc = STDIN_FILENO; if (binary && ! isatty (STDIN_FILENO)) set_binary_mode (STDIN_FILENO, O_BINARY); +#ifdef __hpux + /* Recognize file descriptors closed by the parent on HP-UX. */ + int flags = fcntl (STDIN_FILENO, F_GETFL, NULL); + if (flags >= 0 && (flags & FD_CLOEXEC) != 0) + cmp.file[f].desc = ERRNO_ENCODE (EBADF); + else +#endif if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0) cmp.file[f].desc = ERRNO_ENCODE (errno); else |