lua-users home
lua-l archive

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



I remember having done this years back, by appending "&& echo <returncode>" to the command itself (and being able to read the output).

<returncode> is whatever $ magic bash uses for showing the return code.

Had similar stuff also for Windows, I can dig up the archives if no- one else gives a better solution.

It is a hack.

-asko

John D. Blair kirjoitti 6.6.2009 kello 3:20:

Has anybody worked out how to obtain the exit code from a sub-process
invoked using popen()?

It looks to me that the exit code is currently discarded b/c the
standard __close meta-method only returns a boolean.

Would it be possible to define an alternate close method (i.e.,
pclose()) which one could use to close a stream opened using popen() and obtain the exit code from the sub-process? Has this already been done?

thanks much,
John.