]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(touch): Call close only if necessary.
authorJim Meyering <jim@meyering.net>
Thu, 12 Jun 2003 08:17:49 +0000 (08:17 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 12 Jun 2003 08:17:49 +0000 (08:17 +0000)
src/touch.c

index faec819116bdc5600539d925a45ad9cbe1da760b..7597972b5b5bbf494b53c22fbd1041021ae99e8c 100644 (file)
@@ -1,5 +1,5 @@
 /* touch -- change modification and access times of files
-   Copyright (C) 87, 1989-1991, 1995-2002 Free Software Foundation, Inc.
+   Copyright (C) 87, 1989-1991, 1995-2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -169,7 +169,8 @@ touch (const char *file)
              error (0, errno, _("failed to get attributes of %s"),
                     quote (file));
            }
-         close (fd);
+         if (fd != -1)
+           close (fd);
          return 1;
        }
     }