From: Jim Meyering Date: Thu, 3 Feb 2000 12:16:47 +0000 (+0000) Subject: (O_NDELAY): Define to 0 if not defined. X-Git-Tag: SH-UTILS-2_0f~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e03663fafd03cb54cf2d1e176b903472b1dd871a;p=thirdparty%2Fcoreutils.git (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. --- diff --git a/src/touch.c b/src/touch.c index 5e638005a0..09f5c7cc6d 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;