Re: [Rd] Could Rstd_Busy do something (src/unix/sys-std.c)?

From: Jakson Alves de Aquino <jalvesaq_at_gmail.com>
Date: Sun, 16 Dec 2012 07:56:06 -0300

On Sun, Dec 16, 2012 at 12:49 AM, Simon Urbanek <simon.urbanek_at_r-project.org> wrote:
> Note that you're not using the payload of the pipe at all, so you
> could simply just send a single byte (not that it matters but you
> don't need the 16-byte packets).
>
> Also you don't want to send anything if the signal is already
> enqueued, it's pointless to try to send more (you could clog the
> pipe), so simply use a flag that you set on write and reset it on
> read -- if that flag is set you don't write anything. That will make
> sure that you get only one trigger even if more signals arrived
> while R is busy. Everything is synchronous here so no need to
> worry.
>
> Finally, I wouldn't mess with the signal all the time - just keep it
> active without touching it and use a flag to avoid re-entrance if
> you really think it's necessary.

Thanks for the additional suggestions. It's even better now:

    void handle_winch(int sig){

        if(fired)
            return;
        fired = 1;
        char buf[16];
        *buf = 0;
        if(write(ofd, buf, 1) <= 0)
            REprintf("setwidth error: write <= 0\n");
    }

    static void uih(void *data) {

        char buf[16];
        if(read(ifd, buf, 16) == 0)
            REprintf("setwidth error: read = 0\n");
        R_ToplevelExec(setwidth_Set, NULL);
        fired = 0;

    }

Best,

Jakson



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun 16 Dec 2012 - 11:05:22 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Dec 2012 - 02:42:55 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive