diff options
author | Jim Meyering <jim@meyering.net> | 2000-02-03 12:16:47 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-02-03 12:16:47 +0000 |
commit | e03663fafd03cb54cf2d1e176b903472b1dd871a (patch) | |
tree | 9d110a6d38a532cebac0fd4c3d49d67030080cc0 /src | |
parent | 6d94f760a2e78a5a24b5ec8f769ec71a011c2536 (diff) | |
download | coreutils-e03663fafd03cb54cf2d1e176b903472b1dd871a.tar.xz |
(O_NDELAY): Define to 0 if not defined.
(O_NONBLOCK): Define to O_NDELAY if not defined.
(touch): Open with O_NONBLOCK, so one can touch a fifo without hanging.
Reported by Eric G. Miller via Michael Stone.
Diffstat (limited to 'src')
-rw-r--r-- | src/touch.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/touch.c b/src/touch.c index 5e638005a..09f5c7cc6 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-1999 Free Software Foundation, Inc. + Copyright (C) 87, 1989-1991, 1995-2000 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 @@ -44,6 +44,14 @@ time_t time (); #define CH_ATIME 1 #define CH_MTIME 2 +#if !defined O_NDELAY +# define O_NDELAY 0 +#endif + +#if !defined O_NONBLOCK +# define O_NONBLOCK O_NDELAY +#endif + /* The name by which this program was run. */ char *program_name; @@ -123,7 +131,7 @@ touch (const char *file) if (! no_create) { /* Try to open FILE, creating it if necessary. */ - fd = open (file, O_WRONLY | O_CREAT, + fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd == -1) open_errno = errno; |