lua-users home
lua-l archive

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


 > > I know that io.popen is a poor stepchild---undocumented and unloved
 > > but useful on Unix platforms nevertheless.  (Actually I notice that as
 > > of Lua 5.1 it is evern documented.)  To make io.open even more useful,
 > > I would like to be able to get the exit status returned by pclose(3).
 > > I notice that the specification says only that file:close() returns
 > > a non-nil value on success.  Would it be possible to change the
 > > specification (and implementation) so that if f = io.popen(...),
 > > then f:close() returns the exit status?  What do the Lua team think?
 > 
 > I am not sure that the meaning of the value returned by pclose is
 > standard.  Several man pages say only that -1 means error. But if
 > this status code is really spread and really useful, it should not be
 > difficult to change that for 5.2.

According to the POSIX standard, the return value is meaningful:

   The pclose() function shall close a stream that was opened by popen(),
   wait for the command to terminate, and return the termination status
   of the process that was running the command language interpreter. 

I don't know what happens on Windows.


Norman