I'd much much obliged if one of you could enlighten me as to why touch needs to
treat /dev/stdin as a special case after the file has been opened though.
Wouldn't the following work just as well, with one less system call?
--- a/src/touch.c
+++ b/src/touch.c
@@ -132,8 +132,8 @@ touch (const char *file)
  else if (! (no_create || no_dereference))
    {
      /* Try to open FILE, creating it if necessary. */
-Â Â Â Â Â fd = fd_reopen (STDIN_FILENO, file,
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, MODE_RW_UGO);
+Â Â Â Â Â fd = open (file,
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, MODE_RW_UGO);
      /* 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
@@ -166,9 +166,9 @@ touch (const char *file)
                     (no_dereference && fd == -1) ? AT_SYMLINK_NOFOLLOW : 0)
        == 0);
-Â if (fd == STDIN_FILENO)
+Â if (fd != STDOUT_FILENO)
    {
-Â Â Â Â Â if (close (STDIN_FILENO) != 0)
+Â Â Â Â Â if (close (fd) != 0)