lua-users home
lua-l archive

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

> It appears that the command line Lua interpreter does not trap SIGPIPE:

It does not. lua.c is mostly an ANSI C program. It'd have to be a POSIX
program to trap SIGPIPE.

> rjek@trite:~$ lua
> Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
> > f = assert(io.popen("true", "w"))
> > f:write "Hello, world."
> > f:close()
> rjek@trite:~$ echo $?
> 141

I get this in Linux:

> f = assert(io.popen("true", "w"))
> =f:write "Hello, world."
> =f:close()
Broken pipe
(program exits)

> I'm not sure how the situation could be improved much.

I don't think it can be improved at all if f:write returns true. Of course,
f:write probably just buffers the output because if I replace f:close with
f:flush I get the same error (Broken pipe).