zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Add nonblock to sysopen
@ 2022-03-31  3:58 Matthew Martin
  0 siblings, 0 replies; only message in thread
From: Matthew Martin @ 2022-03-31  3:58 UTC (permalink / raw)
  To: zsh-workers

A while back CcxWrk on IRC noted sysopen doesn't support O_NONBLOCK.

The POSIX spec for open requires O_NONBLOCK; however, since the spec
also requires O_CLOEXEC, O_NOFOLLOW, and O_SYNC, I wrapped nonblock in
an ifdef as well.

While here, the name member of the struct ought to be const.


diff --git a/Doc/Zsh/mod_system.yo b/Doc/Zsh/mod_system.yo
index 399b6fe03..884c3e753 100644
--- a/Doc/Zsh/mod_system.yo
+++ b/Doc/Zsh/mod_system.yo
@@ -62,6 +62,9 @@ suppress updating of the file atime
 item(tt(nofollow))(
 fail if var(file) is a symbolic link
 )
+item(tt(nonblock))(
+the file is opened in nonblocking mode
+)
 item(tt(sync))(
 request that writes wait until data has been physically written
 )
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index ecd4e2546..71745548f 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -280,7 +280,7 @@ bin_syswrite(char *nam, char **args, Options ops, UNUSED(int func))
 }
 
 
-static struct { char *name; int oflag; } openopts[] = {
+static struct { const char *name; int oflag; } openopts[] = {
 #ifdef O_CLOEXEC
     { "cloexec", O_CLOEXEC },
 #else
@@ -296,6 +296,9 @@ static struct { char *name; int oflag; } openopts[] = {
 #endif
 #ifdef O_NOATIME
     { "noatime", O_NOATIME },
+#endif
+#ifdef O_NONBLOCK
+    { "nonblock", O_NONBLOCK},
 #endif
     { "excl", O_EXCL | O_CREAT },
     { "creat", O_CREAT },


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-31  3:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31  3:58 PATCH: Add nonblock to sysopen Matthew Martin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).