[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Signalling during I/O
- From: Reuben Thomas <rrt@...>
- Date: Fri, 30 Jan 2004 17:18:46 +0100 (CET)
> here's what i did: removed the call to signal(i, SIG_DFL) in
> laction() and replaced the 2 calls to signal(SIGINT, ...) in lcall()
> with sig_catch(SIGINT, ...) where sig_catch() is
>
> static void
> sig_catch(int sig, void (*handler)(int))
> {
> struct sigaction sa;
> sa.sa_handler = handler;
> sa.sa_flags = 0;
> sigemptyset(&sa.sa_mask);
> sigaction(sig, &sa, 0); /* XXX ignores errors */
> }
>
> i don't know if these changes create new problems though
> (besides being non-ansi)
Wow, that does it for me.
> to test this hodge podge of signal semantics, i used the following
Hodge-podge? Looks quite simple to me, simpler than what was there
before...
As to whether it's nastier to do it like this or the ANSI way, as Luiz
admits, it's a "corner" of ANSI C (e.g. it doesn't work at all on some
platforms, like EPOC, and it's badly-defined enough that the glibc
manpages advise programmers not to use signal).
Since this doesn't involve a change to liblua or liblualib, I'd be very
much in favour of adding it (at least as an option) to lua.c.
> ----------------------------
> function foobar()
> local a
> if pcall(function() a=io.stdin:read('*a') end) then
> if a=="" then os.exit(0) end -- eof
> io.write(string.gsub(a, "%c", "."), "\n")
> else
> print'boo-boo'
> end
> end
>
> while 1 do foobar() end
> ----------------------------
Nice!
--
http://www.mupsych.org/~rrt/ | fantasize, a. the largest you can imagine