[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [PATCH] luaconf.h: call fflush(NULL) before popen()
- From: Alexey Tourbin <at@...>
- Date: Mon, 27 Aug 2007 02:51:03 +0400
Hello,
popen(3) manual page says:
Since the standard input of a command opened for reading shares
its seek offset with the process that called popen(), if the
original process has done a buffered read, the command's input
position may not be as expected. Similarly, the output from a
command opened for writing may become intermingled with that of
the original process. The latter can be avoided by calling
fflush(3) before popen().
And at least some scripting languages call something like "fflush(NULL)"
before spawning (see e.g. "perldoc -f system").
(And also "fflush(NULL)" is K&R-compatible.)
---
src/luaconf.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/luaconf.h b/src/luaconf.h
index 402c9fe..912a7fc 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -678,7 +678,7 @@ union luai_Cast { double l_d; long l_l; };
#define LUA_USE_POPEN
#if defined(LUA_USE_POPEN)
-#define lua_popen(L,c,m) ((void)L, popen(c,m))
+#define lua_popen(L,c,m) ((void)L, (void)fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
--
1.5.2.5.GIT