summaryrefslogtreecommitdiff
path: root/src/touch.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-06-12 08:17:49 +0000
committerJim Meyering <jim@meyering.net>2003-06-12 08:17:49 +0000
commitaa85d5d6c7100422fc7277537ec71f9e1d99865a (patch)
tree63b94226ad565908e38a0c9612ff62fd5e0aaf28 /src/touch.c
parent738b7eb8e43f53ac726723604b8dfa6b78a6e38e (diff)
downloadcoreutils-aa85d5d6c7100422fc7277537ec71f9e1d99865a.tar.xz
(touch): Call close only if necessary.
Diffstat (limited to 'src/touch.c')
-rw-r--r--src/touch.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/touch.c b/src/touch.c
index faec81911..7597972b5 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -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;
}
}