tech-userlevel archive

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

Re: updates?



Hi Christos,

    I have attached a program to test the delivery order of signals.
It turns out that both Linux and our current implementation use a FIFO
policy to deliver signal, (1. only realtime signals and 2. mix of realtime
signals and standard signals)
I do not know how FreeBSD handles it.
Let me know if there are any problems.

2016-07-23 12:15 GMT-07:00 Charles Cui <charles.cui1984%gmail.com@localhost>:

>
> 2016-07-23 3:10 GMT-07:00 Christos Zoulas <christos%astron.com@localhost>:
>
>> In article <
>> CA+SXE9u+2SNfNC7YoV3c_b52DTCbEk-9iE25+KwZoSh7Fnz4nw%mail.gmail.com@localhost>,
>> Charles Cui  <charles.cui1984%gmail.com@localhost> wrote:
>> >-=-=-=-=-=-
>> >
>> >Hi Christos,
>> >Here is a improved patch based on your code review,
>> >
>> https://github.com/ycui1984/posixtestsuite/blob/master/patches/REALTIME_SIGNAL/0005-improve-error-checking-improve-based-on-code-review.patch
>> >
>> >I will send you the signal test later once I am ready.
>>
>> That looks good. Did you mean to goto discard; instead of goto out;?
>>
> I considered about this, it seems that if the variable kp is successfully
> allocated,
> we need to goto out to free kp first (which prevents memory leak).
> But if we never allocate the variable kp, and encountered an error,
> we need to goto discard, which does not free kp.
> Make sense?
>
>>
>> christos
>>
>>
>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

#define CNT     4
void myhandler(int signo, siginfo_t *info, void *context) {
        printf ("Inside Handler = %d\n", signo);
}

int main()
{
        int pid, i;
        long syslimit;
        union sigval value;
        struct sigaction act;
        int signals[CNT] = {SIGRTMIN+1, SIGINT, SIGRTMIN + 0, SIGRTMIN+2};

        act.sa_flags = SA_SIGINFO;
        act.sa_sigaction = myhandler;
        sigemptyset(&act.sa_mask);
        for (i = 0; i <CNT; i++)
                sigaction(signals[i], &act, 0);

        value.sival_int = 0;
        pid = getpid();

        for (i = 0; i<CNT; i++) sighold(signals[i]);

        for (i=0; i<CNT; i++) {
                if (sigqueue(pid, signals[i], value) != 0) {
                        printf("call to sigqueue did not return success\n");
                }
        }
        for (i = 0; i<CNT; i++) sigrelse(signals[i]);
        sleep(3);
        return 0;
}


Home | Main Index | Thread Index | Old Index