- --- luaext_platform.cc d6b2a9e14b19d3fe6bc6105f3574048a333b118b
+++ luaext_platform.cc 186f18019b766de62254ea6e1a53dd82c08ac00b
@@ -1,7 +1,8 @@
#include "lua.hh"
#include <signal.h>
+#include <string>
#include "platform.hh"
@@ -74,6 +75,28 @@ LUAEXT(spawn_redirected, )
return 1;
}
+LUAEXT(execute_redirout, )
+{
+ std::string out;
+ int n = -lua_gettop(L);
+ const char *path = luaL_checkstring(L, n);
+ n = -n;
+ char **argv = (char**)malloc((n+1)*sizeof(char*));
+ int i;
+ pid_t ret;
+ if (argv==NULL)
+ return 0;
+ argv[0] = (char*)path;
+ for (i=1; i<n; i++) argv[i] = (char*)luaL_checkstring(L, -(n - i));
+ argv[i] = NULL;
+
+ ret = process_execute_redirout(out, argv);
+ free(argv);
+ lua_pushnumber(L, ret);
+ lua_pushstring(L, out.c_str());
+ return 2;
+}
+
LUAEXT(wait, )
{
pid_t pid = static_cast<pid_t>(luaL_checknumber(L, -1));
============================================================