lua-users home
lua-l archive

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


It was thus said that the Great Coda Highland once stated:
> On Fri, Jan 18, 2013 at 4:03 PM, Rena <hyperhacker@gmail.com> wrote:
> 
> > What's the other information returned by system() then? Maybe that
> > should still be given as an additional return value.
> >
> > --
> > Sent from my Game Boy.
> >
> 
> According to man 3 system, the _XOPEN_SOURCE feature test macro
> enables returning flags corresponding to the macros used by wait(2).
> 
> http://linux.die.net/man/2/wait
> 
> Not sure how useful this actually is. I've never needed it.

  I use it. My current job is testing and as such, I use Lua to not only run
the programs (checking return codes and what not) but also to run the
various tests.  The script I have to run one component has this bit (I wrote
a custom module to wrap Unix related process calls [1]):

  if proc.sig.caught(proc.sig.CHLD) then
    io.stderr:write("SCP stopped!\n")
    status = proc.wait()

    if status.status == 'normal' then
      io.stderr:write(string.format("status=normal rc=%d\n",status.rc))
    elseif status.status == 'terminated' then
      io.stderr:write(string.format("status=terminated signal=%q\n",status.description))
    end

    -- some other code ...
  end

It's important to know if the process seg faulted ... 

  -spc (And while not related to Lua, I also have code that does a stack
	trace when a program crashes ... )

[1]	https://github.com/spc476/lua-conmanorg/blob/master/src/process.c

[2]	https://github.com/spc476/CGILib/blob/master/src/crashreport.c