[Rpm-ecosystem] closing stderr in lua scriptlets

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Nov 29 17:13:37 UTC 2015


Hi,

I want to close stderr in lua scriptlet (after posix.fork, before
posix.exec). I'd use posix.close, but it is not exposed in the posix
module provided by rpm. Is there some other way to do this?

I could probably do os.execute('... 2>/dev/null'), but the whole point
of using lua is avoiding the shell...

Zbyszek

PS. This works in plain lua but not in rpm:

posix = require 'posix'
pid = posix.fork()
if pid == 0 then
    posix.close(2)
    posix.open("/dev/null")
    assert(posix.exec("/bin/systemctl", "daemon-reload"))
elseif pid > 0 then
    posix.wait(pid)
end


More information about the Rpm-ecosystem mailing list