lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Does your application change these standard handles just once, at its
startup and before it initializes Lua?  If so, one solution would be
for your application to modify the standard handles, and then "exec"
itself.  Then, stdin/out/err would be setup as CreateProcess says.

If you can't do this, then you can use _fdopen and make use of the
fact that MSVCRT seems to reuse standard FILE slots:

HANDLE h = CreateFooHandle(yadda, yadda, yadda);
FILE *f = _fdopen(_open_osfhandle((long)h, _RD_ONLY), "rb");
assert( f == stdin );  /* hopefully! */
/* rinse, repeat for stdout, stderr */

Yes, this is a dirty, ugly hack.  Please clearly mark it as such in
your comments!