diff options
author | Jim Meyering <jim@meyering.net> | 2005-08-14 14:18:07 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-08-14 14:18:07 +0000 |
commit | 478bd8935b35f410beb59e9b1fcf844bb3aee34b (patch) | |
tree | 709ce504645ad594b8eaf6665ad6198656b5db52 /src | |
parent | 0ad5c9400bcfd95bf50d15c46f160ecdf9a29d4b (diff) | |
download | coreutils-478bd8935b35f410beb59e9b1fcf844bb3aee34b.tar.xz |
Use one fewer file descriptor in a common case.
Include "fd-reopen.h", rather than "fcntl--.h".
Use fd_reopen rather than open.
Diffstat (limited to 'src')
-rw-r--r-- | src/touch.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/touch.c b/src/touch.c index e7008c18a..c7d5c009c 100644 --- a/src/touch.c +++ b/src/touch.c @@ -26,7 +26,7 @@ #include "system.h" #include "argmatch.h" #include "error.h" -#include "fcntl--.h" +#include "fd-reopen.h" #include "getdate.h" #include "posixtm.h" #include "posixver.h" @@ -127,8 +127,9 @@ touch (const char *file) if (! no_create) { /* Try to open FILE, creating it if necessary. */ - fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + fd = fd_reopen (STDIN_FILENO, file, + O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); /* Don't save a copy of errno if it's EISDIR, since that would lead touch to give a bogus diagnostic for e.g., `touch /' (assuming |